feat: add fs tools (#59)
This commit is contained in:
Executable
+15
@@ -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" "$@")"
|
||||
Executable
+14
@@ -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" "$@")"
|
||||
Executable
+15
@@ -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" "$@")"
|
||||
Executable
+15
@@ -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" "$@")"
|
||||
Executable
+20
@@ -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" "$@")"
|
||||
@@ -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" "$@")"
|
||||
Reference in New Issue
Block a user