diff options
| -rwxr-xr-x | tools/fs_cat.sh | 15 | ||||
| -rwxr-xr-x | tools/fs_ls.sh | 14 | ||||
| -rwxr-xr-x | tools/fs_mkdir.sh | 15 | ||||
| -rwxr-xr-x | tools/fs_rm.sh | 15 | ||||
| -rwxr-xr-x | tools/fs_write.sh | 20 | ||||
| -rwxr-xr-x | tools/save_file.sh | 16 |
6 files changed, 79 insertions, 16 deletions
diff --git a/tools/fs_cat.sh b/tools/fs_cat.sh new file mode 100755 index 0000000..e8b3722 --- /dev/null +++ b/tools/fs_cat.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +# @describe Read the contents of a file at the specified path. +# Use this when you need to examine the contents of an existing file. + +# @env FS_BASE_DIR=. The base dir +# @option --path! The path of the file to read + +main() { + path="$FS_BASE_DIR/$argc_path" + cat "$path" +} + +eval "$(argc --argc-eval "$0" "$@")" diff --git a/tools/fs_ls.sh b/tools/fs_ls.sh new file mode 100755 index 0000000..876765a --- /dev/null +++ b/tools/fs_ls.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +# @describe List all files and directories at the specified path. + +# @env FS_BASE_DIR=. The base dir +# @option --path! The path of the directory to list + +main() { + path="$FS_BASE_DIR/$argc_path" + ls -1 "$path" +} + +eval "$(argc --argc-eval "$0" "$@")" diff --git a/tools/fs_mkdir.sh b/tools/fs_mkdir.sh new file mode 100755 index 0000000..7a7e71f --- /dev/null +++ b/tools/fs_mkdir.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +# @describe Create a new directory at the specified path. + +# @env FS_BASE_DIR=. The base dir +# @option --path! The path of the directory to create + +main() { + path="$FS_BASE_DIR/$argc_path" + mkdir -p "$path" + echo "Directory created: $path" +} + +eval "$(argc --argc-eval "$0" "$@")" diff --git a/tools/fs_rm.sh b/tools/fs_rm.sh new file mode 100755 index 0000000..3d84fe8 --- /dev/null +++ b/tools/fs_rm.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +# @describe Remove the file or directory at the specified path. + +# @env FS_BASE_DIR=. The base dir +# @option --path! The path of the file or directory to remove + +main() { + path="$FS_BASE_DIR/$argc_path" + rm -rf "$path" + echo "Path removed: $path" +} + +eval "$(argc --argc-eval "$0" "$@")" diff --git a/tools/fs_write.sh b/tools/fs_write.sh new file mode 100755 index 0000000..bc97c34 --- /dev/null +++ b/tools/fs_write.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e + +# @describe Write the contents to a file at the specified path. +# If the file exists, only the necessary changes will be applied. +# If the file doesn't exist, it will be created. +# Always provide the full intended contents of the file. + +# @env FS_BASE_DIR=. The base dir +# @option --path! The path of the file to write to +# @option --contents! The full contents to write to the file + +main() { + path="$FS_BASE_DIR/$argc_path" + mkdir -p "$(dirname "$path")" + printf "%s" "$argc_contents" > "$path" + echo "The contents written to: $path" +} + +eval "$(argc --argc-eval "$0" "$@")" diff --git a/tools/save_file.sh b/tools/save_file.sh deleted file mode 100755 index f2d14d0..0000000 --- a/tools/save_file.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -# @describe Saves the contents to a file called `file_name` and returns the file path if successful. -# @option --file-name! The name of the file to save to. -# @option --contents! The contents to save. - -main() { - base_dir="${LLM_TOOL_CACHE_DIR:-/tmp}" - output_file="$base_dir/$argc_file_name" - mkdir -p "$(dirname "$output_file")" - echo "$argc_contents" > "$output_file" - echo "$output_file" -} - -eval "$(argc --argc-eval "$0" "$@")" |
