In-place mode (-i)
In-place mode edits one or more files directly on disk. Every write is atomic: nesdit writes to a temporary file in the same directory, then renames it over the target. The target file is either fully updated or fully unchanged — no partial state is ever observable.
Basic usage
Input (config.json):
After the command (config.json on disk):
STDOUT is empty. STDERR is empty on success.
YAML in-place
Input (deploy.yaml):
After the command:
TOML in-place
Input (Chart.toml):
After the command:
Note
nesdit emits TOML using inline-table syntax for nested structures to preserve your key order exactly. Idiomatic [section] TOML is read correctly on input.
Batch mode (multiple files)
Pass multiple files or a shell glob:
After a multi-file run, nesdit prints a summary to stderr:
Tip
Shell globbing (nesdit -i '**/*.yaml' --query '...') works because the shell expands the glob before passing file names to nesdit. nesdit does not perform its own glob expansion.
--backup: keep a copy of the original
Add --backup to save a sibling file before each atomic write:
This creates config.json.bak containing the original bytes. Use a custom suffix with --backup=.orig:
nesdit emits a confirmation to stderr:
Warning
--backup requires -i. Using --backup without -i is a flag-parse error:
Symlinks
When the target is a symlink, nesdit follows it and edits the real file. The symlink itself is preserved.
Flag interactions
| Flag combination | Behaviour |
|---|---|
-i + -n/--dry-run |
--dry-run wins. No file written. A warning is emitted: "-i ignored because --dry-run is set". |
-i + --check |
--check wins. No file written. A warning is emitted. Exits 0 if no drift, 2 if drift. |
-i + --backup |
Allowed. Backup is written before the atomic rename. |
-i + --edit |
Error: "--edit and -i are mutually exclusive". |
-i + --output-format |
Error: "--output-format and -i are mutually exclusive". |
See the DR-001 flag matrix and modes/check for full details.
Related flags
--backup— sibling backup before write.--dry-run/-n— preview the diff without writing.--check— gate on drift without writing.--keep-going— continue after per-file errors in a batch.--create-missing— allow queries to create new keys.