Skip to content

Commit

Permalink
pref: stop parsing CLI options, on encountering -- (#23470)
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman authored Jan 14, 2025
1 parent 9ea3ea3 commit a949f53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/tools/vretry.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ mut:

fn main() {
mut context := Context{}
mut fp := flag.new_flag_parser(os.args#[1..])
args := os.args#[1..]
// dump(args)
mut fp := flag.new_flag_parser(args)
fp.application('v retry')
fp.version('0.0.1')
fp.description('Run the command CMD in a loop, until it succeeds, or until a predetermined amount of seconds pass.')
Expand All @@ -32,6 +34,7 @@ fn main() {
exit(1)
}
cmd := command_args.join(' ')
// dump(cmd)

spawn fn (context Context) {
time.sleep(context.timeout)
Expand Down
5 changes: 3 additions & 2 deletions cmd/tools/vretry_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ fn test_retry() {
assert res.output == run(pass_cmd).output

// Include flags on the cmd as well.
pass_cmd_with_flags := '${vexe} run cmd/tools/check_retry.vsh --list -x arguments'
pass_cmd_with_flags := '${vexe} run cmd/tools/check_retry.vsh --list -x -- -b js arguments'
res = run('${vexe} retry -r 3 -- ${pass_cmd_with_flags}')
dump_on_ci(res)
assert res.exit_code == 0
assert res.output == run(pass_cmd_with_flags).output
output_trimmed := res.output.trim_space()
assert output_trimmed == "['--list', '-x', '--', '-b', 'js', 'arguments']"
}
3 changes: 3 additions & 0 deletions vlib/v/pref/pref.v
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
for i := 0; i < args.len; i++ {
arg := args[i]
match arg {
'--' {
break
}
'-wasm-validate' {
res.wasm_validate = true
}
Expand Down

0 comments on commit a949f53

Please sign in to comment.