fix: scripts/bin.sh convert json to cli options incorrect (#24)
This commit is contained in:
@@ -42,3 +42,5 @@ jobs:
|
|||||||
|
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: argc test
|
run: argc test
|
||||||
|
env:
|
||||||
|
PYTHONIOENCODING: utf-8
|
||||||
+1
-1
@@ -221,7 +221,7 @@ set "bin_dir=%~dp0"
|
|||||||
for %%i in ("%bin_dir:~0,-1%") do set "script_dir=%%~dpi"
|
for %%i in ("%bin_dir:~0,-1%") do set "script_dir=%%~dpi"
|
||||||
set "script_name=%~n0"
|
set "script_name=%~n0"
|
||||||
|
|
||||||
$run "%script_dir%cmd\cmd.$lang" "%script_name%.$lang" %*
|
$run "%script_dir%scripts\bin.$lang" "%script_name%.$lang" %*
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -20,13 +20,15 @@ fi
|
|||||||
|
|
||||||
FUNC_FILE="$LLM_FUNCTIONS_DIR/tools/$FUNC_FILE"
|
FUNC_FILE="$LLM_FUNCTIONS_DIR/tools/$FUNC_FILE"
|
||||||
|
|
||||||
|
export JQ=jq
|
||||||
if [[ "$OS" == "Windows_NT" ]]; then
|
if [[ "$OS" == "Windows_NT" ]]; then
|
||||||
|
export JQ="jq -b"
|
||||||
FUNC_FILE="$(cygpath -w "$FUNC_FILE")"
|
FUNC_FILE="$(cygpath -w "$FUNC_FILE")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$LLM_FUNCTION_ACTION" == "declarate" ]]; then
|
if [[ "$LLM_FUNCTION_ACTION" == "declarate" ]]; then
|
||||||
argc --argc-export "$FUNC_FILE" | \
|
argc --argc-export "$FUNC_FILE" | \
|
||||||
jq -r '
|
$JQ -r '
|
||||||
def parse_description(flag_option):
|
def parse_description(flag_option):
|
||||||
if flag_option.describe == "" then
|
if flag_option.describe == "" then
|
||||||
{}
|
{}
|
||||||
@@ -74,23 +76,26 @@ else
|
|||||||
|
|
||||||
data="$(
|
data="$(
|
||||||
echo "$FUNC_DATA" | \
|
echo "$FUNC_DATA" | \
|
||||||
jq -r '
|
$JQ -r '
|
||||||
to_entries | .[] |
|
to_entries | .[] |
|
||||||
(.key | split("_") | join("-")) as $key |
|
(.key | split("_") | join("-")) as $key |
|
||||||
if .value | type == "array" then
|
if .value | type == "array" then
|
||||||
.value | .[] | "--\($key)\n\(.)"
|
.value | .[] | "--\($key)\n\(. | @json)"
|
||||||
elif .value | type == "boolean" then
|
elif .value | type == "boolean" then
|
||||||
if .value then "--\($key)" else "" end
|
if .value then "--\($key)" else "" end
|
||||||
else
|
else
|
||||||
"--\($key)\n\(.value)"
|
"--\($key)\n\(.value | @json)"
|
||||||
end' | \
|
end'
|
||||||
tr -d '\r'
|
|
||||||
)" || {
|
)" || {
|
||||||
echo "Invalid json data"
|
echo "Invalid json data"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
if [[ "$line" == '--'* ]]; then
|
||||||
ARGS+=("$line")
|
ARGS+=("$line")
|
||||||
|
else
|
||||||
|
ARGS+=("$(echo "$line" | $JQ -r '.')")
|
||||||
|
fi
|
||||||
done <<< "$data"
|
done <<< "$data"
|
||||||
"$FUNC_FILE" "${ARGS[@]}"
|
"$FUNC_FILE" "${ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user