Plaster
New
List
Login
common-lisp
default
anonymous
2021.12.30 20:40:46
(defparameter *tui-pass* (adopt:make-option 'pass :long "pass" :help (format nil "When invoked, prompts the user for a password ~ this password is then hashed and printed to the ~ user.") :short #\p :initial-value nil :reduce (constantly t))) (defparameter *tui-help* (adopt:make-option 'help :long "help" :help (format nil "When invoked, prints the help menu.") :short #\h :initial-value nil :reduce (constantly t))) (defparameter *tui-config* (adopt:make-option 'config :long "config" :help (format nil "When invoked, generates a new config.json") :short #\c :initial-value nil :reduce (constantly t))) (defparameter *tui* (adopt:make-interface :name "BSFE" :summary "Backend for the BSFE events website" :usage "[Optional flags]" :help (format nil "Starts BSFE using config.json") :contents (list *tui-pass* *tui-help* *tui-config*))) (defun query-for-password-to-hash () (format *query-io* "Enter a password to hash: ~%") (let ((val (read-line))) (if (yes-or-no-p (format *query-io* "Is ~A correct?" val)) (format t "~%~A~%Please put this in your config.json~%" (hash-password val)) (query-for-password-to-hash)))) (defun tui-toplevel () (handler-case (multiple-value-bind (arguments options) (adopt:parse-options *tui*) (declare (ignore arguments)) (when (gethash 'help options) (adopt:print-help-and-exit *tui*)) (when (gethash 'pass options) (query-for-password-to-hash) (adopt:exit)) (when (gethash 'config options) (generate-example) (adopt:exit))) (error (c) (adopt:print-error-and-exit c))) (startup-with-config))
Raw
Annotate
Repaste
Edit