Created
March 30, 2021 23:27
-
-
Save JeremyOttley/d9d87630e26c4e8caef7ac3c716a6aa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env joker | |
(ns script | |
(:require [joker.tools.cli :as cli] | |
[joker.os :as os])) | |
(def opts | |
[["-c" "--channel VALUE" "Choose Twitch Channel"] | |
["-v" "--version" "Show version information"] | |
["-h" "--help" "Show this summary"]]) | |
(defn show-options | |
[summary errors] | |
(println "twitch OPTIONS\n") | |
(println summary) | |
(when errors | |
(println "\nErrors:") | |
(run! println errors))) | |
(defn twitch-stream [channel] | |
(os/sh "streamlink" (str "https://www.twitch.tv/" channel) " best")) | |
(let [{:keys [options summary errors]} (cli/parse-opts *command-line-args* opts) | |
{:keys [help channel version]} options] | |
(cond | |
errors | |
(do | |
(show-options summary errors) | |
(os/exit -1)) | |
help | |
(show-options summary nil) | |
version | |
(println "version: 1") | |
(some? channel) | |
(twitch-stream channel) | |
:else | |
(do | |
(show-options summary ["Must enter a value for --channel"]) | |
(os/exit -1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment