Skip to content

feat: add a --format flag for init and export output - #421

Merged
josegonzalez merged 1 commit into
mainfrom
410-add-a-format-flag-for-init-and-export-output
Aug 7, 2026
Merged

feat: add a --format flag for init and export output#421
josegonzalez merged 1 commit into
mainfrom
410-add-a-format-flag-for-init-and-export-output

Conversation

@josegonzalez

Copy link
Copy Markdown
Member

init and export inferred the recipe format from the --output extension, which left --output - able to emit YAML and nothing else. --format yaml|json5 states the format outright and always wins, so a JSON5-native user can finally pipe a recipe out as well as in: docket export --output - --format json5 | docket apply --tasks-format json5 -. Because writing JSON5 into a file named tasks.yml produces something the YAML parser cannot read back, --format json5 with no explicit --output moves the default to tasks.json, and export's companion vars-file to tasks.vars.json. A path the user typed is never rewritten; when its extension then disagrees with the bytes, a warning names the --tasks-format needed to read it back. On export the flag governs the vars-file too, while a vars-file with no --format keeps following its own extension.

parseTasksFormatFlag becomes parseRecipeFormatFlag, taking the flag name so --format and --tasks-format each blame themselves, and the shared completion predictor is renamed to match. format is deliberately not reserved as an input name: only apply, plan, and validate register recipe inputs as flags.

Closes #410. Carved out as follow-ups: #418 for cross-format conversion in fmt, #419 for --vars-output being ignored under --output -, and #420 for init's next-steps block naming the recipe it wrote.

`init` and `export` inferred the recipe format from the `--output` extension, which left `--output -` able to emit YAML and nothing else. `--format yaml|json5` states the format outright and always wins, so a JSON5-native user can finally pipe a recipe out as well as in: `docket export --output - --format json5 | docket apply --tasks-format json5 -`. Because writing JSON5 into a file named `tasks.yml` produces something the YAML parser cannot read back, `--format json5` with no explicit `--output` moves the default to `tasks.json`, and export's companion vars-file to `tasks.vars.json`. A path the user typed is never rewritten; when its extension then disagrees with the bytes, a warning names the `--tasks-format` needed to read it back. On export the flag governs the vars-file too, while a vars-file with no `--format` keeps following its own extension.

`parseTasksFormatFlag` becomes `parseRecipeFormatFlag`, taking the flag name so `--format` and `--tasks-format` each blame themselves, and the shared completion predictor is renamed to match. `format` is deliberately not reserved as an input name: only apply, plan, and validate register recipe inputs as flags.

Closes #410. Carved out as follow-ups: #418 for cross-format conversion in `fmt`, #419 for `--vars-output` being ignored under `--output -`, and #420 for init's next-steps block naming the recipe it wrote.
@josegonzalez
josegonzalez merged commit c4fe87e into main Aug 7, 2026
19 checks passed
@josegonzalez
josegonzalez deleted the 410-add-a-format-flag-for-init-and-export-output branch August 7, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --format flag for init and export output

1 participant