Skip to content

Commit a949f53

Browse files
authored
pref: stop parsing CLI options, on encountering -- (#23470)
1 parent 9ea3ea3 commit a949f53

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cmd/tools/vretry.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ mut:
1212

1313
fn main() {
1414
mut context := Context{}
15-
mut fp := flag.new_flag_parser(os.args#[1..])
15+
args := os.args#[1..]
16+
// dump(args)
17+
mut fp := flag.new_flag_parser(args)
1618
fp.application('v retry')
1719
fp.version('0.0.1')
1820
fp.description('Run the command CMD in a loop, until it succeeds, or until a predetermined amount of seconds pass.')
@@ -32,6 +34,7 @@ fn main() {
3234
exit(1)
3335
}
3436
cmd := command_args.join(' ')
37+
// dump(cmd)
3538

3639
spawn fn (context Context) {
3740
time.sleep(context.timeout)

cmd/tools/vretry_test.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ fn test_retry() {
5353
assert res.output == run(pass_cmd).output
5454

5555
// Include flags on the cmd as well.
56-
pass_cmd_with_flags := '${vexe} run cmd/tools/check_retry.vsh --list -x arguments'
56+
pass_cmd_with_flags := '${vexe} run cmd/tools/check_retry.vsh --list -x -- -b js arguments'
5757
res = run('${vexe} retry -r 3 -- ${pass_cmd_with_flags}')
5858
dump_on_ci(res)
5959
assert res.exit_code == 0
60-
assert res.output == run(pass_cmd_with_flags).output
60+
output_trimmed := res.output.trim_space()
61+
assert output_trimmed == "['--list', '-x', '--', '-b', 'js', 'arguments']"
6162
}

vlib/v/pref/pref.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
343343
for i := 0; i < args.len; i++ {
344344
arg := args[i]
345345
match arg {
346+
'--' {
347+
break
348+
}
346349
'-wasm-validate' {
347350
res.wasm_validate = true
348351
}

0 commit comments

Comments
 (0)