diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-06 05:37:32 +0000 |
|---|---|---|
| committer | sigoden <sigoden@gmail.com> | 2024-06-06 05:37:32 +0000 |
| commit | f58e9ea54a4d46e020ed3b5860a9832f41521e29 (patch) | |
| tree | c022bf851a1a7e6a587db028df3b4177d5075283 | |
| parent | c6eeb84402f50d05002ebbaf2d1652f42ff060aa (diff) | |
| download | llm-functions-docker-f58e9ea54a4d46e020ed3b5860a9832f41521e29.tar.gz | |
refactor: improve scripts/create.sh
| -rw-r--r-- | Argcfile.sh | 6 | ||||
| -rwxr-xr-x | scripts/create.sh | 13 |
2 files changed, 11 insertions, 8 deletions
diff --git a/Argcfile.sh b/Argcfile.sh index ae17100..69bfaa6 100644 --- a/Argcfile.sh +++ b/Argcfile.sh @@ -175,11 +175,7 @@ install() { } # @cmd Create a boilplate tool script file. -# It automatically generate declaration json for `*.py` and `*.js` and generate `@option` tags for `.sh`. -# Examples: -# argc create abc.sh foo bar! baz+ qux* -# @arg name! The script filename. -# @arg params* The script parameters +# @arg args~ create() { ./scripts/create.sh "$@" } diff --git a/scripts/create.sh b/scripts/create.sh index 27e2441..3e20ac1 100755 --- a/scripts/create.sh +++ b/scripts/create.sh @@ -2,20 +2,27 @@ set -e # @describe Create a boilplate tool script file. -# @arg name! The script filename. +# It automatically generate declaration json for `*.py` and `*.js` and generate `@option` tags for `.sh`. +# Examples: +# argc create abc.sh foo bar! baz+ qux* +# @arg name! The script file name. # @arg params* The script parameters main() { - ext="${argc_name##*.}" output="tools/$argc_name" if [[ -f "$output" ]]; then _die "$output already exists" fi + ext="${argc_name##*.}" + support_exts=('.sh' '.js' '.py') + if [[ "$ext" == "$argc_name" ]]; then + _die "No extension name, pelease add one of ${support_exts[*]}" + fi case $ext in sh) create_sh ;; js) create_js ;; py) create_py ;; - *) _die "Invalid extension name: '$ext'" ;; + *) _die "Invalid extension name: $ext, must be one of ${support_exts[*]}" ;; esac } |
