From 7e538d7401fe842164ae8dc17bcc7e7e099c875d Mon Sep 17 00:00:00 2001 From: Tim Basel Date: Thu, 28 May 2020 18:40:09 +0200 Subject: [PATCH] utils: add args to launch_tool --- cmd/v/v.v | 8 ++++---- vlib/v/util/util.v | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/v/v.v b/cmd/v/v.v index 2d80a84448..2c158c1903 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -36,7 +36,7 @@ fn main_v() { if args.len == 0 { println('For usage information, quit V REPL using `exit` and use `v help`') } - util.launch_tool(false, 'vrepl') + util.launch_tool(false, 'vrepl', os.args[1..]) return } args_and_flags := util.join_env_vflags_and_os_args()[1..] @@ -61,7 +61,7 @@ fn main_v() { // Note for future contributors: Please add new subcommands in the `match` block below. if command in simple_cmd { // External tools - util.launch_tool(prefs.is_verbose, 'v' + command) + util.launch_tool(prefs.is_verbose, 'v' + command, os.args[1..]) return } match command { @@ -69,7 +69,7 @@ fn main_v() { invoke_help_and_exit(args) } 'new', 'init' { - util.launch_tool(prefs.is_verbose, 'vcreate') + util.launch_tool(prefs.is_verbose, 'vcreate', os.args[1..]) return } 'translate' { @@ -77,7 +77,7 @@ fn main_v() { return } 'search', 'install', 'update', 'remove' { - util.launch_tool(prefs.is_verbose, 'vpm') + util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..]) return } 'get' { diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index ea5db2d642..d52e0ce5a1 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -102,11 +102,11 @@ pub fn set_vroot_folder(vroot_path string) { os.setenv('VEXE', os.real_path(os.join_path(vroot_path, vname)), true) } -pub fn launch_tool(is_verbose bool, tool_name string) { +pub fn launch_tool(is_verbose bool, tool_name string, args []string) { vexe := pref.vexe_path() vroot := os.dir(vexe) set_vroot_folder(vroot) - tool_args := args_quote_paths_with_spaces(os.args[1..]) + tool_args := args_quote_paths_with_spaces(args) tool_exe := path_of_executable(os.real_path('$vroot/cmd/tools/$tool_name')) tool_source := os.real_path('$vroot/cmd/tools/${tool_name}.v') tool_command := '"$tool_exe" $tool_args'