Mercurial > core / lisp/lib/cli/clap/proto.lisp
changeset 655: |
65102f74d1ae |
parent: |
328e1ff73938
|
child: |
517c65b51e6b |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Mon, 16 Sep 2024 21:28:33 -0400 |
permissions: |
-rw-r--r-- |
description: |
some optimizations, may have muddied the waters with cli-opt a bit though.. tbd |
1 ;;; cli/clap/proto.lisp --- Clap Protocol 6 (in-package :cli/clap/proto) 8 (define-condition clap-condition () ()) 10 (deferror clap-error (clap-condition) ()) 11 (defwarning clap-warning (clap-condition) ()) 12 (deferror clap-simple-error (simple-error clap-error) () (:auto t)) 13 (deferror clap-unknown-argument (clap-error unknown-argument) ()) 14 (deferror clap-missing-argument (clap-error missing-argument) 15 ((kind :initarg :kind :initform nil))) 16 (deferror clap-invalid-argument (clap-error invalid-argument) ()) 17 (defwarning clap-simple-warning (simple-warning clap-warning) () (:auto t))) 19 (defun clap-unknown-argument (arg kind) 20 (error 'clap-unknown-argument :name arg :kind kind)) 22 (defun clap-missing-argument (arg kind) 23 (error 'clap-missing-argument :item arg :kind kind)) 25 (defun clap-invalid-argument (arg &key reason kind) 26 (error 'clap-invalid-argument :name arg :kind kind :reason reason)) 28 (defgeneric push-cmd (cmd place)) 30 (defgeneric push-opt (opt place)) 32 (defgeneric pop-cmd (place)) 34 (defgeneric pop-opt (place)) 36 (defgeneric find-cmd (self name &optional active)) 38 (defgeneric (setf find-cmd) (new self name &optional active)) 40 (defgeneric find-opt (self name &optional active)) 42 (defgeneric (setf find-opt) (new self name &optional active)) 44 (defgeneric find-opts (self name &key active recurse)) 46 (defgeneric active-cmds (self)) 48 (defgeneric active-opts (self &optional global)) 50 (defgeneric activate-opt (self)) 52 (defgeneric activate-cmd (self)) 54 (defgeneric find-short-opts (self ch &key)) 56 (defgeneric call-opt (self arg)) 58 (defgeneric do-opt (self)) 60 (defgeneric do-opts (self &optional global)) 62 (defgeneric call-cmd (self args opts)) 64 (defgeneric do-cmd (self) 65 (:documentation "Run the command SELF with args parsed at runtime.")) 67 (defgeneric print-help (self &optional stream) 68 (:documentation "Format cli SELF as a helpful string.")) 70 (defgeneric print-version (self &optional stream) 71 (:documentation "Print the version of SELF.")) 73 (defgeneric print-usage (self &optional stream) 74 (:documentation "Format cli SELF as a useful string.")) 76 (defgeneric handle-unknown-opt (self opt) 77 (:documentation "Handle an unknown cli-opt.")) 79 (defgeneric handle-missing-opt (self opt) 80 (:documentation "Handle a missing cli-opt.")) 82 (defgeneric handle-invalid-opt (self opt &optional reason) 83 (:documentation "Handle an invalid cli-opt.")) 85 (defgeneric handle-unknown-arg (self arg) 86 (:documentation "Handle an unknown cli-arg.")) 88 (defgeneric handle-missing-arg (self arg) 89 (:documentation "Handle a missing cli-arg.")) 91 (defgeneric handle-invalid-arg (self arg &optional reason) 92 (:documentation "Handle an invalid cli-arg.")) 94 (defgeneric cli-equal (a b))