aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/parser/cli.lux
blob: 83e7d1298e6864bc1e0e7e66b2e07f7b4032f76d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(.using
 [library
  [lux (.except parameter)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: (/.Parser it)
  "A command-line interface parser.")

(documentation: /.result
  "Executes the parser and verifies that all inputs are processed."
  [(result parser inputs)])

(documentation: /.any
  "Just returns the next input without applying any logic.")

(documentation: /.parse
  "Parses the next input with a parsing function."
  [(parse parser)])

(documentation: /.this
  "Checks that a token is in the inputs."
  [(this reference)])

(documentation: /.somewhere
  "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."
  [(somewhere cli)])

(documentation: /.end
  "Ensures there are no more inputs.")

(documentation: /.named
  "Parses a named parameter and yields its value."
  [(named name value)])

(documentation: /.parameter
  "Parses a parameter that can have either a short or a long name."
  [(parameter [short long] value)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Parser
             ..result
             ..any
             ..parse
             ..this
             ..somewhere
             ..end
             ..named
             ..parameter]
            []))