Skip to content

Instantly share code, notes, and snippets.

@JeremyOttley
Created March 30, 2021 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyOttley/d9d87630e26c4e8caef7ac3c716a6aa7 to your computer and use it in GitHub Desktop.
Save JeremyOttley/d9d87630e26c4e8caef7ac3c716a6aa7 to your computer and use it in GitHub Desktop.
#!/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