Skip to content

Read an argument file only from the first argument - #74

Merged
aoreshkov merged 1 commit into
mainfrom
cli-kit-argument-file-first-word
Nov 6, 2026
Merged

aoreshkov merged 1 commit into
mainfrom
cli-kit-argument-file-first-word

Conversation

@aoreshkov

Copy link
Copy Markdown
Owner

Argument files now count only as the first argument: tool @args.txt. Every later word is taken as typed.

As released in 0.4.0, @path was read as a file wherever a new option or operand could start, so any operand that starts with @ became a file name. Trying it on delva-cli, which hasn't turned argument files on:

  • search kv @id 42 failed with exit 66, and needed @@id. Keys such as @id, @type and @timestamp are ordinary in JSON.
  • With a file named id in the working directory, the same command read that file's lines as arguments, printed no hits and exited 0.
  • A mistake such as search kv @.name ada got can't read argument file '.name' instead of the command's own hint.

The first word is the one that can't be data in a program with subcommands, and a whole command line fits in a file, so nothing is lost but mixing the two forms.

  • Expansion: expandArgumentFile replaces a first @path with the file's lines and leaves the rest as typed, so tool @args.txt $.orders works. @@x as the first word is the literal @x, for a program whose root takes operands. The parser no longer has to tell an option's value from a new word, so Parser.expand, Reading and takesNextToken are gone.
  • Now an ordinary word: tool query @args.txt and tool --width 40 @args.txt. The second is unknown subcommand '@args.txt', so options go in the file or after it.
  • Help line: Start with @file to read arguments from it, one per line; @@ for a literal @.
  • Completion: the scripts are unchanged and still step over any @ word. Past the first word, such a word is an operand or a mistake, and names no command either way. demo store @args.txt q leaves the completion tests, since that line no longer means anything.
  • Docs: cli-kit's README section and the KDoc, and a Changed line in cli-kit's changelog. The API is experimental and its signature doesn't change, so the ABI dump doesn't either.

./gradlew check is green on Windows, where the bash completion tests are skipped; CI runs them on Linux.

After cli-kit 0.5.0 is released, delva-cli can turn argument files on with no change to its operands.

🤖 Generated with Claude Code

Expanding @path wherever an operand is read made every operand that
starts with @ a file name: a key such as @id failed, or, with a file of
that name there, silently ran another command. The first word is the one
word that can't be data, and a whole command line fits in the file, so
only it is expanded now; the words after it follow the file's lines as
typed. The parser no longer needs to tell an option's value from a new
word, so expansion moves out of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aoreshkov
aoreshkov force-pushed the cli-kit-argument-file-first-word branch from be02bdb to 7e0d78e Compare November 5, 2026 21:00
@aoreshkov
aoreshkov merged commit b27a696 into main Nov 6, 2026
7 checks passed
@aoreshkov
aoreshkov deleted the cli-kit-argument-file-first-word branch November 6, 2026 06:18
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.

1 participant