Mercurial > core / lisp/lib/cli/clap/proto.lisp
changeset 649: |
6e5006dfe7b8 |
parent: |
95fd920af398
|
child: |
328e1ff73938 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Thu, 12 Sep 2024 22:38:22 -0400 |
permissions: |
-rw-r--r-- |
description: |
clap parsing updates |
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 &optional kind) 20 (error 'clap-unknown-argument :name arg :kind kind)) 22 (defun clap-missing-argument (arg &optional 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 find-opts (self name &key active recurse)) 40 (defgeneric active-cmds (self)) 42 (defgeneric active-opts (self &optional global)) 44 (defgeneric activate-opt (self)) 46 (defgeneric activate-cmd (self)) 48 (defgeneric find-short-opts (self ch &key)) 50 (defgeneric call-opt (self arg)) 52 (defgeneric do-opt (self)) 54 (defgeneric do-opts (self &optional global)) 56 (defgeneric call-cmd (self args opts)) 58 (defgeneric do-cmd (self) 59 (:documentation "Run the command SELF with args parsed at runtime.")) 61 (defgeneric print-help (self &optional stream) 62 (:documentation "Format cli SELF as a helpful string.")) 64 (defgeneric print-version (self &optional stream) 65 (:documentation "Print the version of SELF.")) 67 (defgeneric print-usage (self &optional stream) 68 (:documentation "Format cli SELF as a useful string.")) 70 (defgeneric handle-unknown-opt (self opt) 71 (:documentation "Handle an unknown cli-opt.")) 73 (defgeneric handle-missing-opt (self opt) 74 (:documentation "Handle a missing cli-opt.")) 76 (defgeneric handle-invalid-opt (self opt &optional reason) 77 (:documentation "Handle an invalid cli-opt.")) 79 (defgeneric handle-unknown-arg (self arg) 80 (:documentation "Handle an unknown cli-arg.")) 82 (defgeneric handle-missing-arg (self arg) 83 (:documentation "Handle a missing cli-arg.")) 85 (defgeneric handle-invalid-arg (self arg &optional reason) 86 (:documentation "Handle an invalid cli-arg.")) 88 (defgeneric cli-equal (a b))