feat(tool): fs_write ask confirmation for existing files
This commit is contained in:
+7
-2
@@ -11,8 +11,13 @@ set -e
|
||||
ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
||||
|
||||
main() {
|
||||
"$ROOT_DIR/utils/guard_path.sh" "$argc_path" "Write '$argc_path'?"
|
||||
mkdir -p "$(dirname "$argc_path")"
|
||||
if [[ -f "$argc_path" ]]; then
|
||||
printf "%s" "$argc_contents" | git diff --no-index "$argc_path" - || true
|
||||
"$ROOT_DIR/utils/guard_operation.sh" "Apply changes?"
|
||||
else
|
||||
"$ROOT_DIR/utils/guard_path.sh" "$argc_path" "Write '$argc_path'?"
|
||||
mkdir -p "$(dirname "$argc_path")"
|
||||
fi
|
||||
printf "%s" "$argc_contents" > "$argc_path"
|
||||
echo "The contents written to: $argc_path" >> "$LLM_OUTPUT"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user