Metadata-Version: 2.4
Name: dfgscript
Version: 0.2.0
Summary: A minimal, deterministic, LLM-friendly, line-based file manipulation DSL
License: SOCL
Keywords: file,dsl,llm,text,editing
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# DataForge v0.2

> A minimal, deterministic, LLM-friendly, line-based file manipulation DSL.

## Install

```bash
pip install dfgscript
```

Afterwards three entry points are available:

```bash
dataforge script.dfg          # canonical command
build     script.dfg          # alias matching the spec
py -m dataforge script.dfg    # module invocation
```

---

## Quick example

```dfg
# notes.dfg
create-file "notes.txt"

1+Hello world
2+This is a test file
3+It has some content
4+End of file
```

```bash
dataforge notes.dfg           # write the file
dataforge notes.dfg --dry-run # preview without writing
```

---

## CLI flags

| Flag | Description |
|------|-------------|
| `--dry-run` / `--preview` | Show resulting file; do **not** write anything |
| `--backup-dir PATH` | Save a timestamped `.bak` copy before each write |
| `--log PATH` | Append log output to a file |
| `--verbose` / `-v` | Debug-level logging of every operation |
| `--version` | Print version and exit |

---

## DSL reference

### File-level commands

```
create-file "path"   # create new — error if file exists
replace-file "path"  # unconditional overwrite
change-file "path"   # patch an existing file (creates if absent)
```

### Line-level operations

```
N+<text>      # write/replace line N  (expands file with "" if N > length)
N-"<text>"    # delete line N  only if content matches exactly (warns otherwise)
N><text>      # insert <text> after line N  (shifts tail down)
$+<text>      # append as new final line
```

### Comments & blank lines

```
# This is a comment
```

Blank lines in a `.dfg` are ignored; use `N+` with empty text to create a blank
line in the target file.

---

## Python API

```python
from dataforge import parse, run

source = open("edit.dfg").read()
script = parse(source)                        # → DfgScript
lines  = run(script, dry_run=True)            # → list[str]
lines  = run(script, backup_dir=".backups")   # write + backup
```

---

## License

SOCL
