From b7e6a492b7bc8208d6792ec289115066724a2fd2 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 14 Jul 2024 02:40:58 +0000 Subject: [PATCH 1/2] refactor: argc run@tool/run@agent accept `-C/--cwd` option --- Argcfile.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Argcfile.sh b/Argcfile.sh index 9d17181..16b83dd 100644 --- a/Argcfile.sh +++ b/Argcfile.sh @@ -13,6 +13,7 @@ LANG_CMDS=( \ ) # @cmd Run the tool +# @option -C --cwd Change the current working directory # @alias tool:run # @arg tool![`_choice_tool`] The tool name # @arg json The json data @@ -28,11 +29,13 @@ run@tool() { fi lang="${argc_tool##*.}" cmd="$(_lang_to_cmd "$lang")" - "$cmd" ./scripts/run-tool.$lang "$argc_tool" "$argc_json" + run_tool_script="$PWD/scripts/run-tool.$lang" + (cd "${argc_cwd:-$ARGC_PWD}" && "$cmd" "$run_tool_script" "$argc_tool" "$argc_json") } # @cmd Run the agent # @alias agent:run +# @option -C --cwd Change the current working directory # @arg agent![`_choice_agent`] The agent name # @arg action![`_choice_agent_action`] The agent action # @arg json The json data @@ -49,7 +52,8 @@ run@agent() { tools_path="$(_get_agent_tools_path "$argc_agent")" lang="${tools_path##*.}" cmd="$(_lang_to_cmd "$lang")" - "$cmd" ./scripts/run-agent.$lang "$argc_agent" "$argc_action" "$argc_json" + run_agent_script="$PWD/scripts/run-agent.$lang" + (cd "${argc_cwd:-$ARGC_PWD}" && "$cmd" "$run_agent_script" "$argc_agent" "$argc_action" "$argc_json") } # @cmd Build the project From 2eb9a6ebbb960b0ec09375def0c8ced88974cdb7 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 14 Jul 2024 02:49:21 +0000 Subject: [PATCH 2/2] fix --- Argcfile.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Argcfile.sh b/Argcfile.sh index 16b83dd..16f86ca 100644 --- a/Argcfile.sh +++ b/Argcfile.sh @@ -30,7 +30,8 @@ run@tool() { lang="${argc_tool##*.}" cmd="$(_lang_to_cmd "$lang")" run_tool_script="$PWD/scripts/run-tool.$lang" - (cd "${argc_cwd:-$ARGC_PWD}" && "$cmd" "$run_tool_script" "$argc_tool" "$argc_json") + [[ -n "$argc_cwd" ]] && cd "$argc_cwd" + "$cmd" "$run_tool_script" "$argc_tool" "$argc_json" } # @cmd Run the agent @@ -53,7 +54,8 @@ run@agent() { lang="${tools_path##*.}" cmd="$(_lang_to_cmd "$lang")" run_agent_script="$PWD/scripts/run-agent.$lang" - (cd "${argc_cwd:-$ARGC_PWD}" && "$cmd" "$run_agent_script" "$argc_agent" "$argc_action" "$argc_json") + [[ -n "$argc_cwd" ]] && cd "$argc_cwd" + "$cmd" "$run_agent_script" "$argc_agent" "$argc_action" "$argc_json" } # @cmd Build the project