From 09c1d987f2274e069ec942733ef50eea60698c78 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 13 Jul 2024 19:07:41 -0400 Subject: [PATCH 1/2] Add download function --- bambu.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bambu.sh b/bambu.sh index 0e63e36..0886be3 100755 --- a/bambu.sh +++ b/bambu.sh @@ -100,6 +100,9 @@ function bambu_file() { rm) bambu_rm "$@" ;; + get) + bambu_get "$@" + ;; *) die "Unknown subcommand $subcommand" ;; @@ -143,6 +146,32 @@ function bambu_rm() { curl_ftps_command "" -Q "DELE /$file" > /dev/null 2>&1 || echo "Failed to delete file $file" } +function bambu_get() { + local file="" + local output_path="$PWD" + + while [ ! -z "$1" ]; do + case "$1" in + -o|--output) + output_path="$2" + shift + shift + ;; + -*) + die "Unknown option $1" + ;; + *) + file="$1" + shift + ;; + esac + done + + [ -z "$file" ] && die "Path to file not specified" + + curl_ftps_command "$file" -o "$output_path/$(basename "$file")" +} + function bambu_print() { local subcommand="$1" shift From 726d20b8f73f07fd0ca23dd17e8975a0a1239744 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 13 Jul 2024 19:08:13 -0400 Subject: [PATCH 2/2] upload -> put --- bambu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bambu.sh b/bambu.sh index 0886be3..d410dd0 100755 --- a/bambu.sh +++ b/bambu.sh @@ -94,8 +94,8 @@ function bambu_file() { ls) bambu_ls "$@" ;; - upload) - bambu_upload "$@" + put]) + bambu_put "$@" ;; rm) bambu_rm "$@" @@ -136,7 +136,7 @@ function bambu_ls() { fi } -function bambu_upload() { +function bambu_put() { local directory="$(preprocess_directory_path "$2")" curl_ftps_command "$directory" -T "$1" }