aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/cli.lux
blob: 7af7405a9bc6e1462d5bb554257cf9239623d935 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(.module:
  [lux (#- Name)
   [abstract
    ["." equivalence (#+ Equivalence)]]
   [control
    ["<>" parser
     ["." cli (#+ Parser)]]]
   [data
    ["." text]]]
  [//
   [repository (#+ Identity)]
   ["/" profile (#+ Name)]])

(type: #export Compilation
  #Build
  #Test)

(structure: any-equivalence
  (Equivalence Any)

  (def: (= reference subject)
    true))

(def: compilation-equivalence
  (Equivalence Compilation)
  (equivalence.sum ..any-equivalence
                   ..any-equivalence))

(def: compilation
  (Parser Compilation)
  (<>.or (cli.this "build")
         (cli.this "test")))

(type: #export Command
  #Version
  #Clean
  #POM
  #Dependencies
  #Install
  (#Deploy Text Identity)
  (#Compilation Compilation)
  (#Auto Compilation))

(def: #export equivalence
  (Equivalence Command)
  ($_ equivalence.sum
      ## #Version
      ..any-equivalence
      ## #Clean
      ..any-equivalence
      ## #POM
      ..any-equivalence
      ## #Dependencies
      ..any-equivalence
      ## #Install
      ..any-equivalence
      ## #Deploy
      ($_ equivalence.product
          text.equivalence
          text.equivalence
          text.equivalence)
      ## #Compilation
      ..compilation-equivalence
      ## #Auto
      ..compilation-equivalence))

(def: command'
  (Parser Command)
  ($_ <>.or
      (cli.this "version")
      (cli.this "clean")
      (cli.this "pom")
      (cli.this "deps")
      (cli.this "install")
      (<>.after (cli.this "deploy")
                (<>.and cli.any
                        (<>.and cli.any
                                cli.any)))
      ..compilation
      (<>.after (cli.this "auto")
                ..compilation)
      ))

(def: #export command
  (Parser [Name Command])
  ($_ <>.either
      (<>.after (cli.this "with")
                ($_ <>.and
                    cli.any
                    ..command'))
      (\ <>.monad map (|>> [/.default])
         ..command')
      ))