diff options
author | Colin Okay <okay@toyful.space> | 2022-02-18 13:55:10 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-18 13:55:10 -0600 |
commit | 4d2afc4e3c6cc5ce5be4f0d421da49ca6cead09a (patch) | |
tree | b35a02ecbade5622c0f4f54d450f54870a5dc10d /build-app.lisp | |
parent | f4b6c94bbd91d5061f1a449f407999be7e8e5814 (diff) |
logging in, redeeming tokens
Diffstat (limited to 'build-app.lisp')
-rw-r--r-- | build-app.lisp | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/build-app.lisp b/build-app.lisp index 1b16837..bd51d54 100644 --- a/build-app.lisp +++ b/build-app.lisp @@ -12,8 +12,17 @@ ;;; HELP TEXTS (defparameter +invite-help-text+ - "") + " +New contributor accounts are added to the your oneliners server by +redeeming invite tokens. +When the --redeem option is passed, the ARGS section is expected to be +three items long, and is interpreted as TOKEN USERNAME PASSWORD. E.g.: + + ol --redeem PHONEYTOKEN c00lhacker my1337pw + +Would attempt to make a new user named c00lhacker with password +my1337pw.") ;;; CLON SYNOPSIS DEFINITION @@ -21,9 +30,9 @@ (group (:header "Search") (text :contents "Usage: ol [OPTIONS] [TERMS ...]") (text :contents "Each term may be a command name or some tag like 'server' or 'tunnel'") - (lispobj :long-name "count" + (lispobj :long-name "limit" :argument-type :optional - :argument-name "Count" + :argument-name "NUMBER" :default-value 10 :description "The maximum number of results to return." :typespec 'integer) @@ -50,13 +59,12 @@ (flag :long-name "update-interactive" :description "Interactively edit a oneliner and update the wiki.")) (group (:header "Admin" :hidden t) + (flag :long-name "login" + :description "Attempt to login to your contributor account. ARGS are interpreted as USERNAME PASSWORD. Success will return ab API token, writing it automatically into your config file.") (flag :long-name "invite" :description "Request an invite token to send to a friend.") - (stropt :long-name "redeem" - :argument-type :optional - :default-value "DUMMY-TOKEN" - :argument-name "TOKEN" - :description "Redeem an invite token. See also --help-topic=invites")) + (flag :long-name "redeem" + :description "Redeem an invite token. See also --help-topic=invites")) (group (:header "Invites" :hidden t) (text :contents +invite-help-text+))) @@ -82,25 +90,35 @@ than the users." (when (getopt :long-name "help") (help ) (uiop:quit)) - (a:when-let (topic (getopt :long-name "help-topic")) (help :item (find-group-with-header (symbol-name topic))) (uiop:quit)) - - (let ((arguments (remainder))) - - (unless arguments + (handler-case + (let ((arguments (remainder))) + (cond + ((getopt :long-name "redeem") + (destructuring-bind (token name pass) arguments + (cli::redeem-invite token name pass))) + ((getopt :long-name "login") + (destructuring-bind (user pass) arguments + (cli::login user pass))) + (arguments + ;; when the first argument is a number, try run a oneliner + (a:when-let (hist-number (parse-integer (first arguments) :junk-allowed t)) + (format t "TBD: Going to run command ~a with arguments ~a~%" + hist-number (rest arguments)) + (uiop:quit)) + ;; otherwise search for oneliners + (cli::search-for-oneliners arguments + (getopt :long-name "limit") + (getopt :long-name "not-flagged"))) + (t + (help))) + (uiop:quit)) + (error (e) + (format *error-output* "ERROR: ~a~%" e) (help) - (uiop:quit)) - - (alexandria:when-let (hist-number (parse-integer (first arguments) :junk-allowed t)) - (format t "TBD: Going to run command ~a with arguments ~a~%" - hist-number (rest arguments)) - (uiop:quit)) - - (cli:search-for-oneliners arguments :)) - - (uiop:quit)) + (uiop:quit)))) ;;; DUMP EXECUTABLE |