about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-01-06 21:24:56 +0100
committerSoispha <soispha@vhack.eu>2024-01-06 21:24:56 +0100
commit1c665e9d8d1d9c3c9895e04eaacbe4744a65167a (patch)
tree1e51364a7f2d9a5f3a07416cbb06dc2633315874
parentfix(hm/pkgs/scr/specific/ytcc/yts): Recognize '' as a command (diff)
downloadnixos-config-1c665e9d8d1d9c3c9895e04eaacbe4744a65167a.tar.gz
nixos-config-1c665e9d8d1d9c3c9895e04eaacbe4744a65167a.zip
feat(hm/pkgs/scr/specific/ytcc/yts): Add cli interface
Diffstat (limited to '')
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/ytcc/yts40
1 files changed, 39 insertions, 1 deletions
diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/yts b/hm/soispha/pkgs/scripts/specific/ytcc/yts
index 1e8f1c8e..4d6cc6e6 100755
--- a/hm/soispha/pkgs/scripts/specific/ytcc/yts
+++ b/hm/soispha/pkgs/scripts/specific/ytcc/yts
@@ -19,7 +19,45 @@ help_text="
 # These lines can be re-ordered; they are executed from top to bottom.
 # vim: ft=gitrebase"
 
-table="$(ytcc --output json list | jq --raw-output 'map("pick \(.id) \(.title) (\(.playlists | map(.name) | join(", "))) [\(.duration | gsub("^\\s+|\\s+$";""))]") | join("\n")')"
+for arg in "$@"; do
+    case "$arg" in
+        "--help")
+            help;
+            exit 0;
+            ;;
+        "--version")
+            version;
+            exit 0;
+            ;;
+    esac
+done
+
+case "$1" in
+    "order")
+        shift 1;
+        case "$1" in
+            "date")
+                    set -- "--order-by" "publish_date" "desc"
+                ;;
+            "raw")
+                shift 1;
+                if [ -n "$1" ]; then
+                    [ -z "$2" ] && die "A first argument to 'order raw' requires a second"
+                    set -- "--order-by" "$1" "$2"
+                fi
+                ;;
+            *)
+                die "'$1' is not a valid subcommand for 'order'; See '--help' for a list";
+                ;;
+        esac
+        ;;
+    *)
+        die "'$1' is not a valid subcommand; See '--help' for a list";
+        ;;
+esac
+
+
+table="$(ytcc --output json list "$@" | jq --raw-output 'map("pick \(.id) \(.title) (\(.playlists | map(.name) | join(", "))) [\(.duration | gsub("^\\s+|\\s+$";""))]") | join("\n")')"
 
 selection_file="$(mktmp)";