Repository navigation
[Feat] Add CLI variable injection (-p/--parameter) and custom INPUT path (-in/--input) (PART I) - #8089
Open
ZhouXY-PKU wants to merge 3 commits into
Open
[Feat] Add CLI variable injection (-p/--parameter) and custom INPUT path (-in/--input) (PART I)#8089ZhouXY-PKU wants to merge 3 commits into
ZhouXY-PKU wants to merge 3 commits into
Conversation
Agent Governance Check
|
This branch has not been deployed
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.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
Part 1 of 2 of the CLI variable-injection feature. This PR implements the
command-line parsing layer and the
-in/--inputwiring; the actualsubstitution of
${var}/$varinside INPUT is delivered by PART II(
ReadInputsignature extension + token-level substitution), which dependson this PR. No dedicated issue exists for the split; this PR body serves as
the phase tracker.
Unit Tests and/or Case Tests for my changes
ParseCommandLineTestpass (short/long form,last-wins for repeated
-p,-incombination, default input path,missing-value/empty-name/digit-leading-name/unknown-option/truncated-argc
all throw).
test_parse_argspassthrough unchanged.--helpoutput now lists-p, --parameterand-in, --input(text addedto
show_general_help()so it flows through the existing-hpath).-in INPUT.alt: reads the given file,running_scf.logshowsglobal_in_card = INPUT.alt,OUT.AltRun/INPUT.alt.infowritten;default run (no
-in) byte-identical to pre-change behavior.behavior verified unchanged on 104_PW_NC_magnetic, and all changes are
gated behind new flags that default to prior behavior.
-pon INPUT values: not applicable in PART I(see "What's changed"); the parsed variables are validated and stored but
do not yet affect INPUT. Covered in PART II with its own tests
(
test_var_substitute, read-input token substitution, variable keyword).What's changed?
User-visible changes:
-p, --parameter <name> <value>(repeatable, last wins): parse-timevalidated (non-empty, non-digit-leading, alnum/underscore name), stored in
ModuleIO::CommandLineArgs::varsand forwarded toDriver::init().In PART I these values are not yet applied to INPUT parameters — that
is PART II (
ReadInputvariable substitution). Accepted and validated nowso the CLI contract is frozen early and PART II only touches the INPUT layer.
-in, --input <file>(defaultINPUT): fully functional. Overrides theINPUT file path for reading, the
global_in_cardline inrunning_*.log,and the
INPUT.infofilename in the output directory.--help/-htext extended accordingly (inshow_general_help(), thesingle source of help text;
parse_command_line's own usage string remainsminimal and is only shown on CLI error paths).
one-line message; existing flags (
-h,--version,--search,--check-input,--generate-parameters-yaml) behave exactly as before.Developer-facing changes:
source_io/parse_command_line.{h,cpp}(new):CommandLineArgs{vars, input_file}andparse_command_line(argc, argv).parse_argsforwards-p/-intokens to it (additive change; all pre-existing flags handledwhere they were before).
source_main/driver.{h,cpp}:Driver::init/atomic_world/readingtakeconst ModuleIO::CommandLineArgs&;reading()passescli.input_fileexplicitly to
read_parameters(PARAM, cli.input_file),print_start_info(input_card), and theINPUT.infopath;print_start_infogains a named
input_cardparameter. No globals added; everything flowsthrough explicit parameters (governance rule 1).
source_io/input_help.cpp: help text for the two new options only.Governance Notes
untouched. Docs PR to follow in PART II when
-ptakes effect(documenting
${var}/$varsyntax,variablekeyword, precedencecommand line > INPUT
variable> built-in default, and-in).CLI flags, extended
--help, and theglobal_in_cardlog line /INPUT.infofilename now reflecting-in's value (previously alwaysINPUT).Changes are confined to
source_io(parse/help) andsource_main(driver wiring).
read_parameterskeeps its two-parameter signature inthis PR; PART II will extend it and update its call sites
(
driver.cppand read-input tests) — no default parameters are used(governance rule 5).
System_para::global_in_cardis now effectively dead in the main flow:all three of its former consumers in
driver.cpp(read path, log line,INPUT.infopath) readcli.input_fileexplicitly instead. The memberis kept because (a) removing it is an unrelated refactor that would bloat
this feature diff, and (b) a full-repo audit is required first (para_json
serialization, tests, downstream forks). Planned follow-up: audit with
grep -rn "global_in_card" source/, then a standalone cleanup commitremoving the member and updating any stragglers.
parse_command_line's internal usage string intentionally duplicates no--helpcontent; on CLI errors it should print the minimal hint plusRun 'abacus -h' for usage.(kept minimal to avoid text drift withshow_general_help()).