Changeset 25 in code
- Timestamp:
- May 14, 2025, 3:07:30 AM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kanako
r24 r25 1 1 #!/bin/sh 2 # $YakumoLabs: kanako,v 2. 22025/05/14 02:07:06 yakumo_izuru Exp $2 # $YakumoLabs: kanako,v 2.3 2025/05/14 02:07:06 yakumo_izuru Exp $ 3 3 4 4 kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" … … 10 10 exit 1 11 11 } 12 _info() { 13 printf "\033[1;32m%s\033[0m\n" "$*" 14 } 12 15 _warn() { 13 printf "\033[1;3 5m%s\033[0m\n" "$*"16 printf "\033[1;33m%s\033[0m\n" "$*" 14 17 } 15 18 … … 27 30 rm "${1%%.enc}" 28 31 else 29 _warn " %s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc"32 _warn "${1%%.enc}.enc does not exist, maybe there was a typo on your end?" 30 33 fi 31 34 } … … 55 58 if [ -z "$(command -v oathtool)" ]; then 56 59 _die "Required dependency 'oathtool' not found" 57 58 60 fi 59 61 totp_seed=$(view "$1" | grep 'totp: ' | head -n1 | cut -d' ' -f2) … … 63 65 } 64 66 delete_directory() { 65 rm -r -i "$1" 67 _warn "Will be removing $1" 68 _warn "Are you okay with that?" 69 read junk 70 case ${junk} in 71 n|N) _info "Abort" ;; 72 y|Y) rm -rf "${1}" && _info "Removed $1";; 73 esac 66 74 } 67 75 delete_file() { 68 rm -i "${1}${2}".enc 76 _warn "Will be removing $1" 77 _warn "Are you okay with that?" 78 read junk 79 case ${junk} in 80 n|N) _info "Abort" ;; 81 y|Y) rm -f "${1}.enc" && _info "Removed $1/$2";; 82 esac 69 83 } 70 84 usage() { 71 printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0"72 printf "The arguments for all switches are relative to \${kanako_store_dir}\n"73 printf "which is located at %s\n" "${kanako_store_dir}"85 _info "Usage: kanako [-ceglnorRv] args" 86 _info "The arguments for all switches are relative to \${kanako_store_dir}" 87 _info "which is located at ${kanako_store_dir}" 74 88 exit 75 89 } … … 77 91 if [ -f "${1%%.enc}".enc ]; then 78 92 ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc 79 elif [ -d "${1:-.}" ]; then80 list "${1:-.}"81 93 else 82 94 usage … … 84 96 } 85 97 86 case $1 in 87 -c) copy $2 ;; 88 -e) edit $2 ;; 89 -g) gen $2 ;; 90 -l) list $2 ;; 91 -n) new $2 ;; 92 -o) otp $2 ;; 93 -R) delete_directory $2 ;; 94 -r) delete_file $2 ;; 95 -v) view $2 ;; 98 cmd="$1" 99 arg="$2" 100 101 case ${cmd} in 102 -c) copy ${arg} ;; 103 -e) edit ${arg} ;; 104 -g) gen ${arg} ;; 105 -h) usage ;; 106 -l) list ${arg} ;; 107 -n) new ${arg} ;; 108 -o) otp ${arg} ;; 109 -r) delete_file ${arg} ;; 110 -R) delete_directory ${arg} ;; 111 -v) view ${arg} ;; 96 112 *) usage ;; 97 113 esac
Note:
See TracChangeset
for help on using the changeset viewer.