From b27cd78b05f506e59ee9a8a0c9ff90560f55bf37 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 18 Jan 2024 22:05:30 +0000 Subject: feat: current --- src/bashly.yml | 3 ++ src/current_command.sh | 1 + tama | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 src/current_command.sh diff --git a/src/bashly.yml b/src/bashly.yml index b6f3b73..9685972 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -12,6 +12,9 @@ commands: - name: upcoming alias: u help: Upcoming anime + - name: current + alias: c + help: Currently airing anime - name: search alias: s args: diff --git a/src/current_command.sh b/src/current_command.sh new file mode 100644 index 0000000..1e7cb98 --- /dev/null +++ b/src/current_command.sh @@ -0,0 +1 @@ +print "/current" diff --git a/tama b/tama index c10a093..a7f9c3b 100755 --- a/tama +++ b/tama @@ -37,6 +37,7 @@ tama_usage() { printf " %s Trending anime\n" "trending " printf " %s Popular anime\n" "popular " printf " %s Upcoming anime\n" "upcoming " + printf " %s Currently airing anime\n" "current " printf " %s Search for a number of anime\n" "search " printf " %s Watch an anime by episode\n" "watch " printf " %s An anime's episodes\n" "episodes " @@ -154,6 +155,38 @@ tama_upcoming_usage() { fi } +# :command.usage +tama_current_usage() { + if [[ -n $long_usage ]]; then + printf "tama current - Currently airing anime\n" + echo + + else + printf "tama current - Currently airing anime\n" + echo + + fi + + printf "Alias: c\n" + echo + + printf "%s\n" "Usage:" + printf " tama current\n" + printf " tama current --help | -h\n" + echo + + # :command.long_usage + if [[ -n $long_usage ]]; then + printf "%s\n" "Options:" + + # :command.usage_fixed_flags + printf " %s\n" "--help, -h" + printf " Show this help\n" + echo + + fi +} + # :command.usage tama_search_usage() { if [[ -n $long_usage ]]; then @@ -430,6 +463,13 @@ tama_upcoming_command() { } +# :command.function +tama_current_command() { + # src/current_command.sh + print "/current" + +} + # :command.function tama_search_command() { # src/search_command.sh @@ -571,6 +611,13 @@ parse_requirements() { shift $# ;; + current | c) + action="current" + shift + tama_current_parse_requirements "$@" + shift $# + ;; + search | s) action="search" shift @@ -767,6 +814,50 @@ tama_upcoming_parse_requirements() { } +# :command.parse_requirements +tama_current_parse_requirements() { + # :command.fixed_flags_filter + while [[ $# -gt 0 ]]; do + case "${1:-}" in + --help | -h) + long_usage=yes + tama_current_usage + exit + ;; + + *) + break + ;; + + esac + done + + # :command.command_filter + action="current" + + # :command.parse_requirements_while + while [[ $# -gt 0 ]]; do + key="$1" + case "$key" in + + -?*) + printf "invalid option: %s\n" "$key" >&2 + exit 1 + ;; + + *) + # :command.parse_requirements_case + # :command.parse_requirements_case_simple + printf "invalid argument: %s\n" "$key" >&2 + exit 1 + + ;; + + esac + done + +} + # :command.parse_requirements tama_search_parse_requirements() { # :command.fixed_flags_filter @@ -1068,6 +1159,7 @@ run() { "trending") tama_trending_command ;; "popular") tama_popular_command ;; "upcoming") tama_upcoming_command ;; + "current") tama_current_command ;; "search") tama_search_command ;; "watch") tama_watch_command ;; "episodes") tama_episodes_command ;; -- cgit v1.2.3