about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-07-28 21:36:38 -0500
committerCase Duckworth2022-07-28 21:36:38 -0500
commiteb6164bd523e85180c352d5a5b0a653cfde6f561 (patch)
tree6bac2393207ec9f02d5583a7ee2294ad00dc8bd1
parentBegin converting to fennel (diff)
downloadradish-eb6164bd523e85180c352d5a5b0a653cfde6f561.tar.gz
radish-eb6164bd523e85180c352d5a5b0a653cfde6f561.zip
Modularize
This ... doesn't work.
-rw-r--r--lib.fnl24
-rw-r--r--pls.fnl5
-rw-r--r--radish.fnl89
-rw-r--r--util.fnl13
4 files changed, 77 insertions, 54 deletions
diff --git a/lib.fnl b/lib.fnl new file mode 100644 index 0000000..a08fcc8 --- /dev/null +++ b/lib.fnl
@@ -0,0 +1,24 @@
1;;; LIB.fnl
2;; Radish library
3
4(local util (require :util))
5
6(local radish {})
7
8(lambda radish.play [?station]
9 (print "play"))
10
11(lambda radish.kill []
12 (print "kill"))
13
14(lambda radish.add [?station]
15 (print "add"))
16
17(lambda radish.del [?station]
18 (print "del"))
19
20(lambda radish.edit [?station]
21 (print "edit"))
22
23radish
24
diff --git a/pls.fnl b/pls.fnl index 0ba2fb8..4d55dd5 100644 --- a/pls.fnl +++ b/pls.fnl
@@ -3,3 +3,8 @@
3;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net> 3;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net>
4;; License: Good Choices (https://acdw.casa/gcl) 4;; License: Good Choices (https://acdw.casa/gcl)
5 5
6(local pls {})
7
8
9
10pls
diff --git a/radish.fnl b/radish.fnl index 4ce6e22..acba83f 100644 --- a/radish.fnl +++ b/radish.fnl
@@ -3,64 +3,45 @@
3;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net> 3;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net>
4;; License: Good Choices (https://acdw.casa/gcl) 4;; License: Good Choices (https://acdw.casa/gcl)
5 5
6;;; Entry point 6(local util (require :util))
7(local pls (require :pls))
8(local radish (require :lib))
7 9
8(fn usage [] 10(fn usage []
9 (printn* "RADISH: a tuner for various streams" 11 (util.printlns "RADISH: a tuner for various streams"
10 "Copyright (C) 2022 Case Duckworth <acdw@acdw.net>" 12 "Copyright (C) 2022 Case Duckworth <acdw@acdw.net>"
11 "License: Good Choices (https://acdw.casa/gcl)" 13 "License: Good Choices (https://acdw.casa/gcl)"
12 "" 14 ""
13 "Commands" 15 "Commands"
14 " radish [STATION]" 16 " radish [STATION]"
15 " Begin playing STATION. If STATION is not" 17 " Begin playing STATION. If STATION is not"
16 " provided, display a list of favorites and" 18 " provided, display a list of favorites and"
17 " allow the user to choose one to play." 19 " allow the user to choose one to play."
18 " radish play [STATION]" 20 " radish play [STATION]"
19 " Begin playing STATION. If STATION is not" 21 " Begin playing STATION. If STATION is not"
20 " provided, play the most recently-played." 22 " provided, play the most recently-played."
21 " radish kill" 23 " radish kill"
22 " Kill the currently-playing station." 24 " Kill the currently-playing station."
23 " radish add [STATION]" 25 " radish add [STATION]"
24 " Add STATION or the currently-playing one" 26 " Add STATION or the currently-playing one"
25 " to the favorites list." 27 " to the favorites list."
26 " radish del [STATION]" 28 " radish del [STATION]"
27 " Remove STATION or the currently-playing" 29 " Remove STATION or the currently-playing"
28 " one from the favorites list." 30 " one from the favorites list."
29 " radish edit [STATION]" 31 " radish edit [STATION]"
30 " Edit the information of STATION, or the" 32 " Edit the information of STATION, or the"
31 " current one if not given." 33 " current one if not given."
32 "" 34 ""
33 "See radish(1) for more details.")) 35 "See radish(1) for more details."))
34 36
35(fn main [args] 37(fn main [args]
36 (match args 38 (match args
37 [:play ?station] (radish-play ?station) 39 [:play ?station] (radish.play ?station)
38 [:kill] (radish-kill) 40 [:kill] (radish.kill)
39 [:add ?station] (radish-add ?station) 41 [:add ?station] (radish.add ?station)
40 [:del ?station] (radish-del ?station) 42 [:del ?station] (radish.del ?station)
41 [:edit ?station] (radish-edit ?station) 43 [:edit ?station] (radish.edit ?station)
42 [station] (radish-play station) 44 [station] (radish.play station)
43 _ (usage))) 45 _ (usage)))
44 46
45;;; Utilities 47(main arg)
46
47(lambda printn* [?sep ...]
48 "Print arguments as strings, delimited by ?SEP.
49?SEP defaults to '\n', but can be anything."
50 (print (table.concat [...] (or ?sep "\n"))))
51
52;;; Functionality
53
54(lambda radish-play [?station])
55
56(lambda radish-kill [])
57
58(lambda radish-add [?station])
59
60(lambda radish-del [?station])
61
62(lambda radish-edit [?station])
63
64;;; End
65
66(main args)
diff --git a/util.fnl b/util.fnl new file mode 100644 index 0000000..c884a01 --- /dev/null +++ b/util.fnl
@@ -0,0 +1,13 @@
1;;; UTIL.fnl
2;; Utility functions
3;; Copyright (C) 2022 Case Duckworth <acdw@acdw.net>
4;; License: Good Choices (https://acdw.casa/gcl)
5
6(local util {})
7
8(lambda util.printlns [?sep ...]
9 "Print arguments as strings, delimited by ?SEP.
10?SEP defaults to '\n', but can be anything."
11 (print (table.concat [...] (or ?sep "\n"))))
12
13util