Browse Source

add Assess (-a) option to clingon commands (check config. file).

This new CLI feature allows the user to check the schema of their configuration
file. The check is to make sure their file's schema is correct. It doesn't check
to make sure their access tokens and Id's are valid. This feature is just a
quick way to make sure you've not mangled your configuration file by deleting a
comma or made a typo. when naming a key, in the JSON object.
master
Craig Oates 3 months ago
parent
commit
e6637e646f
  1. 21
      src/cli.lisp

21
src/cli.lisp

@ -30,16 +30,22 @@
(clingon:make-command
:name "dup"
:description "Update IP addresses associated with your DNS records."
:version "0.0.1"
:version "2024.02.04.01"
:license "MIT"
:authors '("Craig Oates <craig@craigoates.net>")
:usage "[-v] [-c <PATH>] [-m <PATH>] [-t]"
:usage "[-v] [-a <PATH>] [-c <PATH>] [-m <PATH>] [-t 1]"
:options (top-level/options)
:handler #'top-level/handler))
(defun top-level/options ()
"Creates and returns the options for the top-level command"
(list
(clingon:make-option
:string
:description "Assesses and validates config. file at specified path."
:short-name #\a
:long-name "assess"
:key :assess)
(clingon:make-option
:string
:description "Load a config. file at specified path."
@ -57,7 +63,7 @@
:key :make)
(clingon:make-option
:boolean
:description "Test Telegram notification system."
:description "Test Telegram notification system (1 = True/Yes)."
:short-name #\t
:long-name "telegram-test"
:key :telegram-test)
@ -72,16 +78,23 @@
"The top-level handler.
If no configuration file (path) is provided, the program will use the default
one (hard-coded into this function."
(let ((config (clingon:getopt cmd :config))
(let ((assess (clingon:getopt cmd :assess))
(config (clingon:getopt cmd :config))
(make (clingon:getopt cmd :make))
(telegram-test (clingon:getopt cmd :telegram-test))
(verbose (clingon:getopt cmd :verbose)))
(when (> verbose 0)
(format t "Assess File: ~A~%"
(if (null assess) "~/ddns-updater.json" assess))
(format t "Configuration File: ~A~%"
(if (null config) "~/ddns-updater.json" config))
(format t "Make File: ~A~%" (if (null make) "N/A" make))
(format t "Telegram Test: ~A~%" (if (null telegram-test) "No" "Yes"))
(format t "Verbosity Level: ~A~%" verbose))
;; Assess Config. File
(when assess
(utils:check-config-file assess)
(return-from top-level/handler))
;; Make configuration file.
(when make
(utils:make-config-file make)

Loading…
Cancel
Save