diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-05 21:07:40 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-05 21:07:40 +0800 |
| commit | a7834c98fcbe491c59ab4b0689380fd84596f5ee (patch) | |
| tree | 34b5b8b633cf0f63e35f3a96e25ed54b36906be5 /tools/fs_write.sh | |
| parent | 74789b5a72cd8e3261f196f4e7197ddba92947d0 (diff) | |
| download | llm-functions-docker-a7834c98fcbe491c59ab4b0689380fd84596f5ee.tar.gz | |
feat: add fs tools (#59)
Diffstat (limited to 'tools/fs_write.sh')
| -rwxr-xr-x | tools/fs_write.sh | 20 |
1 files changed, 20 insertions, 0 deletions
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" "$@")" |
