feat: add argument-file BOM handling and expandvars pragma - #40
Merged
Conversation
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>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two argument-file features needed for the Robot Framework migration (robotframework/robotframework#5773), plus a small negation fix.
BOM handling
read_argument_filenow reads files asutf-8-sig, so a leading UTF-8 BOM is silently ignored instead of leaking a\ufeffinto the first token.# expandvars:pragmaWhen 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:$NAMEand${NAME}-> environment variableNAME${NAME=default}->defaultwhenNAMEis unset$$-> literal$CliUsageError: Processing argument file '<path>' failed: Variable 'NAME' does not exist.$1bad) ->CliUsageErrorread_argument_file/split_argument_filetake an optionalenviron=mapping (defaults toos.environ) for testability.Joined negation + abbreviation
The joined negation form (
--nostatusrc) now also resolves through unambiguous-prefix abbreviation whencli_allow_abbrevandcli_ignore_hyphensare enabled (e.g.--nostatus/--NoStatus), matching the separator--no-statusform which already abbreviated.Notes
[Unreleased]CHANGELOG entry (release-please automated).ruff,ruff format,mypy --strictclean; 333 tests pass (12 new).