aboutsummaryrefslogtreecommitdiffstats
path: root/Argcfile.sh
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-14 10:51:00 +0800
committerGitHub <noreply@github.com>2024-07-14 10:51:00 +0800
commita4087408a27eeeb15ef2b6e193b16a6848759668 (patch)
treeed0abb69d4a59d4deb52c4ea495ecb9cf9948080 /Argcfile.sh
parentec999c7c51d80577272088cb9912e1520f943933 (diff)
downloadllm-functions-docker-a4087408a27eeeb15ef2b6e193b16a6848759668.tar.gz
refactor: argc run@tool/run@agent accept `-C/--cwd` option (#75)
Diffstat (limited to 'Argcfile.sh')
-rw-r--r--Argcfile.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/Argcfile.sh b/Argcfile.sh
index 9d17181..16f86ca 100644
--- a/Argcfile.sh
+++ b/Argcfile.sh
@@ -13,6 +13,7 @@ LANG_CMDS=( \
)
# @cmd Run the tool
+# @option -C --cwd <dir> Change the current working directory
# @alias tool:run
# @arg tool![`_choice_tool`] The tool name
# @arg json The json data
@@ -28,11 +29,14 @@ 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"
+ [[ -n "$argc_cwd" ]] && cd "$argc_cwd"
+ "$cmd" "$run_tool_script" "$argc_tool" "$argc_json"
}
# @cmd Run the agent
# @alias agent:run
+# @option -C --cwd <dir> 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 +53,9 @@ 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"
+ [[ -n "$argc_cwd" ]] && cd "$argc_cwd"
+ "$cmd" "$run_agent_script" "$argc_agent" "$argc_action" "$argc_json"
}
# @cmd Build the project