about summary refs log tree commit diff stats
path: root/radish.fnl
blob: 4ce6e22a61603e1e9f2d0e64fa0869ef0ad4ce8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
;;; RADISH
;; A tuner for various streams
;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net>
;; License: Good Choices (https://acdw.casa/gcl)

;;; Entry point

(fn usage []
  (printn* "RADISH: a tuner for various streams"
           "Copyright (C) 2022 Case Duckworth <acdw@acdw.net>"
           "License: Good Choices (https://acdw.casa/gcl)"
           ""
           "Commands"
           "    radish [STATION]"
           "        Begin playing STATION.  If STATION is not"
           "        provided, display a list of favorites and"
           "        allow the user to choose one to play."
           "    radish play [STATION]"
           "        Begin playing STATION.  If STATION is not"
           "        provided, play the most recently-played."
           "    radish kill"
           "        Kill the currently-playing station."
           "    radish add [STATION]"
           "        Add STATION or the currently-playing one"
           "        to the favorites list."
           "    radish del [STATION]"
           "        Remove STATION or the currently-playing"
           "        one from the favorites list."
           "    radish edit [STATION]"
           "        Edit the information of STATION, or the"
           "        current one if not given."
           ""
           "See radish(1) for more details."))

(fn main [args]
  (match args
    [:play ?station] (radish-play ?station)
    [:kill] (radish-kill)
    [:add ?station] (radish-add ?station)
    [:del ?station] (radish-del ?station)
    [:edit ?station] (radish-edit ?station)
    [station] (radish-play station)
    _ (usage)))

;;; Utilities

(lambda printn* [?sep ...]
  "Print arguments as strings, delimited by ?SEP.
?SEP defaults to '\n', but can be anything."
  (print (table.concat [...] (or ?sep "\n"))))

;;; Functionality

(lambda radish-play [?station])

(lambda radish-kill [])

(lambda radish-add [?station])

(lambda radish-del [?station])

(lambda radish-edit [?station])

;;; End

(main args)