aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/compositor/cli.lux
blob: e36de70982f320640b278db8f949eb7c5b0c42e6 (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
(.using
  [library
   [lux {"-" Module Source}
    [control
     [pipe {"+" case>}]
     ["<>" parser
      ["[0]" cli {"+" Parser}]]]
    [tool
     [compiler
      [meta
       [archive
        [descriptor {"+" Module}]]]]]
    [world
     [file {"+" Path}]]]])

(type: .public Source
  Path)

(type: .public Host_Dependency
  Path)

(type: .public Library
  Path)

(type: .public Target
  Path)

(type: .public Compilation
  [(List Source) (List Host_Dependency) (List Library) Target Module])

(type: .public Export
  [(List Source) Target])

(type: .public Service
  (Variant
   {#Compilation Compilation}
   {#Interpretation Compilation}
   {#Export Export}))

(template [<name> <long> <type>]
  [(def: <name>
     (Parser <type>)
     (cli.named <long> cli.any))]

  [source_parser "--source" Source]
  [host_dependency_parser "--host_dependency" Host_Dependency]
  [library_parser "--library" Library]
  [target_parser "--target" Target]
  [module_parser "--module" Module]
  )

(def: .public service
  (Parser Service)
  ($_ <>.or
      (<>.after (cli.this "build")
                ($_ <>.and
                    (<>.some ..source_parser)
                    (<>.some ..host_dependency_parser)
                    (<>.some ..library_parser)
                    ..target_parser
                    ..module_parser))
      (<>.after (cli.this "repl")
                ($_ <>.and
                    (<>.some ..source_parser)
                    (<>.some ..host_dependency_parser)
                    (<>.some ..library_parser)
                    ..target_parser
                    ..module_parser))
      (<>.after (cli.this "export")
                ($_ <>.and
                    (<>.some ..source_parser)
                    ..target_parser))
      ))

(def: .public target
  (-> Service Target)
  (|>> (case> (^or {#Compilation [sources host_dependencies libraries target module]}
                   {#Interpretation [sources host_dependencies libraries target module]}
                   {#Export [sources target]})
              target)))