changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 652: 328e1ff73938
parent: 6e5006dfe7b8
child: 65102f74d1ae
author: Richard Westhaver <ellis@rwest.io>
date: Sat, 14 Sep 2024 23:55:38 -0400
permissions: -rw-r--r--
description: graph and cli updates
1 ;;; cli/clap/proto.lisp --- Clap Protocol
2 
3 ;;
4 
5 ;;; Code:
6 (in-package :cli/clap/proto)
7 
8 (define-condition clap-condition () ())
9 (eval-always
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)))
18 
19 (defun clap-unknown-argument (arg kind)
20  (error 'clap-unknown-argument :name arg :kind kind))
21 
22 (defun clap-missing-argument (arg kind)
23  (error 'clap-missing-argument :item arg :kind kind))
24 
25 (defun clap-invalid-argument (arg &key reason kind)
26  (error 'clap-invalid-argument :name arg :kind kind :reason reason))
27 
28 (defgeneric push-cmd (cmd place))
29 
30 (defgeneric push-opt (opt place))
31 
32 (defgeneric pop-cmd (place))
33 
34 (defgeneric pop-opt (place))
35 
36 (defgeneric find-cmd (self name &optional active))
37 
38 (defgeneric find-opts (self name &key active recurse))
39 
40 (defgeneric active-cmds (self))
41 
42 (defgeneric active-opts (self &optional global))
43 
44 (defgeneric activate-opt (self))
45 
46 (defgeneric activate-cmd (self))
47 
48 (defgeneric find-short-opts (self ch &key))
49 
50 (defgeneric call-opt (self arg))
51 
52 (defgeneric do-opt (self))
53 
54 (defgeneric do-opts (self &optional global))
55 
56 (defgeneric call-cmd (self args opts))
57 
58 (defgeneric do-cmd (self)
59  (:documentation "Run the command SELF with args parsed at runtime."))
60 
61 (defgeneric print-help (self &optional stream)
62  (:documentation "Format cli SELF as a helpful string."))
63 
64 (defgeneric print-version (self &optional stream)
65  (:documentation "Print the version of SELF."))
66 
67 (defgeneric print-usage (self &optional stream)
68  (:documentation "Format cli SELF as a useful string."))
69 
70 (defgeneric handle-unknown-opt (self opt)
71  (:documentation "Handle an unknown cli-opt."))
72 
73 (defgeneric handle-missing-opt (self opt)
74  (:documentation "Handle a missing cli-opt."))
75 
76 (defgeneric handle-invalid-opt (self opt &optional reason)
77  (:documentation "Handle an invalid cli-opt."))
78 
79 (defgeneric handle-unknown-arg (self arg)
80  (:documentation "Handle an unknown cli-arg."))
81 
82 (defgeneric handle-missing-arg (self arg)
83  (:documentation "Handle a missing cli-arg."))
84 
85 (defgeneric handle-invalid-arg (self arg &optional reason)
86  (:documentation "Handle an invalid cli-arg."))
87 
88 (defgeneric cli-equal (a b))