changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > core / lisp/lib/cli/clap/proto.lisp

revision 419: 0f0e5f9b5c55
parent 404: 66059a1117bd
child 426: 3e721a3349a0
     1.1--- a/lisp/lib/cli/clap/proto.lisp	Thu Jun 06 00:15:14 2024 -0400
     1.2+++ b/lisp/lib/cli/clap/proto.lisp	Thu Jun 06 17:24:19 2024 -0400
     1.3@@ -0,0 +1,68 @@
     1.4+;;; cli/clap/proto.lisp --- Clap Protocol
     1.5+
     1.6+;; 
     1.7+
     1.8+;;; Code:
     1.9+
    1.10+(deferror clap-error (std-error) () (:auto t))
    1.11+
    1.12+;; (defun treat-as-argument (condition)
    1.13+;;   "A handler which can be used to invoke the `treat-as-argument' restart"
    1.14+;;   (invoke-restart (find-restart 'treat-as-argument condition)))
    1.15+
    1.16+;; (defun discard-argument (condition)
    1.17+;;   "A handler which can be used to invoke the `discard-argument' restart"
    1.18+;;   (invoke-restart (find-restart 'discard-argument condition)))
    1.19+
    1.20+(defgeneric push-cmd (cmd place))
    1.21+
    1.22+(defgeneric push-opt (opt place))
    1.23+
    1.24+(defgeneric pop-cmd (place))
    1.25+
    1.26+(defgeneric pop-opt (place))
    1.27+
    1.28+(defgeneric find-cmd (self name &optional active))
    1.29+
    1.30+(defgeneric find-opts (self name &key active recurse))
    1.31+
    1.32+(defgeneric active-cmds (self))
    1.33+
    1.34+(defgeneric active-opts (self &optional global))
    1.35+
    1.36+(defgeneric find-short-opts (self ch &key))
    1.37+
    1.38+(defgeneric call-opt (self arg))
    1.39+
    1.40+(defgeneric do-opt (self))
    1.41+
    1.42+(defgeneric call-cmd (self args opts))
    1.43+
    1.44+(defgeneric parse-args (self args &key &allow-other-keys)
    1.45+  (:documentation "Parse list of strings ARGS using SELF.
    1.46+
    1.47+A list of the same length as ARGS is returned containing 'cli-ast'
    1.48+objects: (OPT . (or char string)) (CMD . string) NIL"))
    1.49+
    1.50+(defgeneric do-cmd (self)
    1.51+  (:documentation "Run the command SELF with args parsed at runtime."))
    1.52+
    1.53+(defgeneric print-help (self &optional stream)
    1.54+  (:documentation "Format cli SELF as a helpful string."))
    1.55+
    1.56+(defgeneric print-version (self &optional stream)
    1.57+  (:documentation "Print the version of SELF."))
    1.58+
    1.59+(defgeneric print-usage (self &optional stream)
    1.60+  (:documentation "Format cli SELF as a useful string."))
    1.61+
    1.62+(defgeneric handle-unknown-argument (self arg)
    1.63+  (:documentation "Handle an unknown argument."))
    1.64+
    1.65+(defgeneric handle-missing-argument (self arg)
    1.66+  (:documentation "Handle a missing argument."))
    1.67+
    1.68+(defgeneric handle-invalid-argument (self arg)
    1.69+  (:documentation "Handle an invalid argument."))
    1.70+
    1.71+(defgeneric cli-equal (a b))