From 3d2228af3085934f43313547b01c4569686bc924 Mon Sep 17 00:00:00 2001 From: Turiiya Date: Thu, 6 Jun 2024 03:09:18 +0200 Subject: [PATCH 1/5] fix --- vlib/v/pref/pref.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 44b3aafff6ea0e..09f7e6c25a7854 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -962,8 +962,10 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin // arguments for e.g. fmt should be checked elsewhere continue } - if res.is_vsh && command_idx < i { - // Allow for `script.vsh abc 123 -option`, because -option is for the .vsh program, not for v + if command_idx < i && (res.is_vsh || (is_source_file(command) && command in known_external_commands)) { + // When running programs, let them be responsible for the arguments passed to them. + // E.g.: `script.vsh cmd -opt` or `v run hello_world.v -opt`. + // But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`. continue } if command == 'doc' { From 5e54142ffe6c1135c97d9c951fa6885ede86e0ca Mon Sep 17 00:00:00 2001 From: Turiiya Date: Thu, 6 Jun 2024 03:20:19 +0200 Subject: [PATCH 2/5] format --- vlib/v/pref/pref.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 09f7e6c25a7854..99ad4915bfb023 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -962,7 +962,8 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin // arguments for e.g. fmt should be checked elsewhere continue } - if command_idx < i && (res.is_vsh || (is_source_file(command) && command in known_external_commands)) { + if command_idx < i && (res.is_vsh || (is_source_file(command) + && command in known_external_commands)) { // When running programs, let them be responsible for the arguments passed to them. // E.g.: `script.vsh cmd -opt` or `v run hello_world.v -opt`. // But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`. From 40a11d6ffcb203103f7a11cd310a535b092e075b Mon Sep 17 00:00:00 2001 From: Turiiya Date: Thu, 6 Jun 2024 03:19:36 +0200 Subject: [PATCH 3/5] remove now obsolete condition that only worked for single `doc` command --- vlib/v/pref/pref.v | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 99ad4915bfb023..0c87419298ab36 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -969,10 +969,6 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin // But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`. continue } - if command == 'doc' { - // Allow for `v doc -comments file.v` - continue - } err_detail := if command == '' { '' } else { ' for command `${command}`' } eprintln_exit('Unknown argument `${arg}`${err_detail}') } From 9aadc2595a39407195e5afef4d11d50bd2e1ffe4 Mon Sep 17 00:00:00 2001 From: Turiiya Date: Thu, 6 Jun 2024 17:48:39 +0200 Subject: [PATCH 4/5] add print --- vlib/v/pref/pref.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 0c87419298ab36..0cb591d10f3fac 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -964,6 +964,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin } if command_idx < i && (res.is_vsh || (is_source_file(command) && command in known_external_commands)) { + if is_source_file(command) && os.is_dir(command) { + eprintln('Found `${command}` directory the in the working directory.\nUse `v ${command}/` to target it instead of running the V command.') + } // When running programs, let them be responsible for the arguments passed to them. // E.g.: `script.vsh cmd -opt` or `v run hello_world.v -opt`. // But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`. From f7cf9846cb306b115d1b3c68949b6f6826b785bf Mon Sep 17 00:00:00 2001 From: Turiiya Date: Fri, 7 Jun 2024 03:40:34 +0200 Subject: [PATCH 5/5] Revert "add print", keep for seperate PR This reverts commit 9aadc2595a39407195e5afef4d11d50bd2e1ffe4. --- vlib/v/pref/pref.v | 3 --- 1 file changed, 3 deletions(-) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 0cb591d10f3fac..0c87419298ab36 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -964,9 +964,6 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin } if command_idx < i && (res.is_vsh || (is_source_file(command) && command in known_external_commands)) { - if is_source_file(command) && os.is_dir(command) { - eprintln('Found `${command}` directory the in the working directory.\nUse `v ${command}/` to target it instead of running the V command.') - } // When running programs, let them be responsible for the arguments passed to them. // E.g.: `script.vsh cmd -opt` or `v run hello_world.v -opt`. // But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`.