feat: add fs tools (#59)

This commit is contained in:
sigoden
2024-07-05 21:07:40 +08:00
committed by GitHub
parent 74789b5a72
commit a7834c98fc
6 changed files with 79 additions and 16 deletions
+20
View File
@@ -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" "$@")"