Changeset 25 in code


Ignore:
Timestamp:
May 14, 2025, 3:07:30 AM (4 weeks ago)
Author:
yakumo.izuru
Message:

私はジュースが好きです、ジュースはいいです

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kanako

    r24 r25  
    11#!/bin/sh
    2 # $YakumoLabs: kanako,v 2.2 2025/05/14 02:07:06 yakumo_izuru Exp $
     2# $YakumoLabs: kanako,v 2.3 2025/05/14 02:07:06 yakumo_izuru Exp $
    33
    44kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}"
     
    1010    exit 1
    1111}
     12_info() {
     13    printf "\033[1;32m%s\033[0m\n" "$*"
     14}
    1215_warn() {
    13     printf "\033[1;35m%s\033[0m\n" "$*"
     16    printf "\033[1;33m%s\033[0m\n" "$*"
    1417}
    1518
     
    2730        rm "${1%%.enc}"
    2831    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?"
    3033    fi
    3134}
     
    5558    if [ -z "$(command -v oathtool)" ]; then
    5659        _die "Required dependency 'oathtool' not found"
    57 
    5860    fi
    5961    totp_seed=$(view "$1" | grep 'totp: ' | head -n1 | cut -d' ' -f2)
     
    6365}
    6466delete_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
    6674}
    6775delete_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
    6983}
    7084usage() {
    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}"
    7488    exit
    7589}
     
    7791    if [ -f "${1%%.enc}".enc ]; then
    7892        ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc
    79     elif [ -d "${1:-.}" ]; then
    80         list "${1:-.}"
    8193    else
    8294        usage
     
    8496}
    8597
    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 ;;
     98cmd="$1"
     99arg="$2"
     100
     101case ${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} ;;
    96112    *) usage ;;
    97113esac
Note: See TracChangeset for help on using the changeset viewer.