Skip to content

feat: add argument-file BOM handling and expandvars pragma - #40

Merged
bhirsz merged 1 commit into
mainfrom
feat/argfile-expandvars
Aug 31, 2026
Merged

feat: add argument-file BOM handling and expandvars pragma#40
bhirsz merged 1 commit into
mainfrom
feat/argfile-expandvars

Conversation

@bhirsz

@bhirsz bhirsz commented Aug 31, 2026

Copy link
Copy Markdown
Member

Adds two argument-file features needed for the Robot Framework migration (robotframework/robotframework#5773), plus a small negation fix.

BOM handling

read_argument_file now reads files as utf-8-sig, so a leading UTF-8 BOM is silently ignored instead of leaking a \ufeff into the first token.

# expandvars: pragma

When the first line of an argument file is a truthy # expandvars: <bool> pragma, the whole file is expanded before being split into lines (so a variable can expand to a full option line). Rules mirror Robot Framework:

  • $NAME and ${NAME} -> environment variable NAME
  • ${NAME=default} -> default when NAME is unset
  • $$ -> literal $
  • unset variable without a default -> CliUsageError: Processing argument file '<path>' failed: Variable 'NAME' does not exist.
  • malformed reference (e.g. $1bad) -> CliUsageError

read_argument_file/split_argument_file take an optional environ= mapping (defaults to os.environ) for testability.

Joined negation + abbreviation

The joined negation form (--nostatusrc) now also resolves through unambiguous-prefix abbreviation when cli_allow_abbrev and cli_ignore_hyphens are enabled (e.g. --nostatus / --NoStatus), matching the separator --no-status form which already abbreviated.

Notes

  • No [Unreleased] CHANGELOG entry (release-please automated).
  • ruff, ruff format, mypy --strict clean; 333 tests pass (12 new).

Read argument files as utf-8-sig so a leading UTF-8 BOM is ignored, and
support an optional first-line `# expandvars: <bool>` pragma that expands
`\`/`\`/`\` references from the environment
(with `\$\$` as a literal `\$`) before splitting the file into tokens.
Failed expansion raises CliUsageError with a Robot Framework-style message.

Also let the joined negation form (`--nostatusrc`) resolve through
unambiguous-prefix abbreviation when `cli_allow_abbrev` and
`cli_ignore_hyphens` are enabled, matching the separator form.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bhirsz
bhirsz merged commit daabb4a into main Aug 31, 2026
8 checks passed
@bhirsz
bhirsz deleted the feat/argfile-expandvars branch August 31, 2026 16:10
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