aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/cli.lux
blob: 666e5a701bccb7a01d33e38fb0b54fe2333d15bf (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
(.module:
  [lux (#- Name)
   [abstract
    ["." equivalence (#+ Equivalence)]]
   [control
    ["<>" parser
     ["." cli (#+ Parser)]]]
   [data
    ["." text]]]
  [//
   [upload (#+ User Password)]
   ["/" 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
  #POM
  #Dependencies
  #Install
  (#Deploy Text User Password)
  (#Compilation Compilation)
  (#Auto Compilation))

(def: #export equivalence
  (Equivalence Command)
  ($_ equivalence.sum
      ## #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 "pom")
      (cli.this "deps")
      (cli.this "install")
      (<>.after (cli.this "deploy")
                ($_ <>.and
                    cli.any
                    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')
      ))