From eb6164bd523e85180c352d5a5b0a653cfde6f561 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 28 Jul 2022 21:36:38 -0500 Subject: Modularize This ... doesn't work. --- lib.fnl | 24 +++++++++++++++++ pls.fnl | 5 ++++ radish.fnl | 89 ++++++++++++++++++++++++-------------------------------------- util.fnl | 13 +++++++++ 4 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 lib.fnl create mode 100644 util.fnl diff --git a/lib.fnl b/lib.fnl new file mode 100644 index 0000000..a08fcc8 --- /dev/null +++ b/lib.fnl @@ -0,0 +1,24 @@ +;;; LIB.fnl +;; Radish library + +(local util (require :util)) + +(local radish {}) + +(lambda radish.play [?station] + (print "play")) + +(lambda radish.kill [] + (print "kill")) + +(lambda radish.add [?station] + (print "add")) + +(lambda radish.del [?station] + (print "del")) + +(lambda radish.edit [?station] + (print "edit")) + +radish + diff --git a/pls.fnl b/pls.fnl index 0ba2fb8..4d55dd5 100644 --- a/pls.fnl +++ b/pls.fnl @@ -3,3 +3,8 @@ ;; Copyright (C) 2022 Case Duckworth ;; License: Good Choices (https://acdw.casa/gcl) +(local pls {}) + + + +pls diff --git a/radish.fnl b/radish.fnl index 4ce6e22..acba83f 100644 --- a/radish.fnl +++ b/radish.fnl @@ -3,64 +3,45 @@ ;; Copyright (C) 2022 Case Duckworth ;; License: Good Choices (https://acdw.casa/gcl) -;;; Entry point +(local util (require :util)) +(local pls (require :pls)) +(local radish (require :lib)) (fn usage [] - (printn* "RADISH: a tuner for various streams" - "Copyright (C) 2022 Case Duckworth " - "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.")) + (util.printlns "RADISH: a tuner for various streams" + "Copyright (C) 2022 Case Duckworth " + "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) + [: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) +(main arg) diff --git a/util.fnl b/util.fnl new file mode 100644 index 0000000..c884a01 --- /dev/null +++ b/util.fnl @@ -0,0 +1,13 @@ +;;; UTIL.fnl +;; Utility functions +;; Copyright (C) 2022 Case Duckworth +;; License: Good Choices (https://acdw.casa/gcl) + +(local util {}) + +(lambda util.printlns [?sep ...] + "Print arguments as strings, delimited by ?SEP. +?SEP defaults to '\n', but can be anything." + (print (table.concat [...] (or ?sep "\n")))) + +util -- cgit 1.4.1-21-gabe81