about summary refs log tree commit diff
path: root/pkgs/profpatsch/dhallsh/completion.dhall
blob: 9df63144c2b8e223b25142f8ae10a6e991fb0629 (plain) (blame)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
let Void =
      https://raw.githubusercontent.com/sellout/dada/master/Void/Type sha256:a413d5091ac5fb02410f02bdbede12eacd89ae52a933a6d24bb68eadbff92613

let Option =
      { short :
          Optional Text
      , long :
          Text
      , description :
          Text
      , argument :
          Optional Text
      }

let Command =
        λ(a : Type)
      → { name :
            Text
        , description :
            Text
        , options :
            List Option
        , subcommands :
            List a
        }

let opt =
        λ(long : Text)
      → λ(description : Text)
      → { long =
            long
        , description =
            description
        , argument =
            None Text
        , short =
            None Text
        }

let fileOpt =
        opt "file" "Read expression from a file instead of standard input"
      ⫽ { argument = Some "FILE" }

let alphaOpt = opt "alpha" "α-normalize expression"

let inplaceOpt =
        opt "inplace" "Modify the specified file in-place"
      ⫽ { argument = Some "FILE" }

let jsonOpt = opt "json" "Use JSON representation of CBOR"

let leafCommand =
        λ(name : Text)
      → λ(description : Text)
      → { options =
            [] : List Option
        , subcommands =
            [] : List Void
        , name =
            name
        , description =
            description
        }

in    { name =
          "dhall"
      , description =
          "Interpreter for the Dhall language"
      , options =
          [ opt "annotate" "Add a type annotation to the output"
          , alphaOpt
          , opt "explain" "Explain error messages in more detail"
          , opt "plain" "Disable syntax highlighting"
          , opt "ascii" "Format code using only ASCII syntax"
          ,   opt "standard-version" "The standard version to use"
            ⫽ { argument = Some "X.Y.Z" }
          ]
      , subcommands =
          [ leafCommand
            "version"
            "Display version"
          ,   leafCommand "resolve" "Resolve an expression's imports"
            ⫽ { options =
                  [ fileOpt
                  , opt "dot" "Output import dependency graph in dot format"
                  , opt
                    "immediate-dependencies"
                    "List immediate import dependencies"
                  , opt
                    "transitive-dependencies"
                    "List transitive import dependencies"
                  ]
              }
          ,   leafCommand "type" "Infer an expression's type"
            ⫽ { options = [ fileOpt ] }
          ,   leafCommand "normalize" "Normalize an expression"
            ⫽ { options = [ fileOpt, alphaOpt ] }
          , leafCommand "repl" "Interpret expressions in a REPL"
          , leafCommand
            "diff"
            "Render the difference between the normal form of two expressions"
          , leafCommand "hash" "Compute semantic hashes for Dhall expressions"
          ,   leafCommand "lint" "Improve Dhall code"
            ⫽ { options = [ inplaceOpt ] }
          ,   leafCommand "format" "Formatter for the Dhall language"
            ⫽ { options =
                  [ opt "check" "Only check if the input is formatted"
                  , inplaceOpt
                  ]
              }
          ,   leafCommand
              "freeze"
              "Add integrity checks to remote import statements of an expression"
            ⫽ { options =
                  [ inplaceOpt
                  , opt
                    "all"
                    "Add integrity checks to all imports (not just remote imports)"
                  , opt
                    "cache"
                    "Add fallback unprotected imports when using integrity checks purely for caching purposes"
                  ]
              }
          ,   leafCommand "encode" "Encode a Dhall expression to binary"
            ⫽ { options = [ fileOpt, jsonOpt ] }
          ,   leafCommand "decode" "Decode a Dhall expression from binary"
            ⫽ { options = [ fileOpt, jsonOpt ] }
          ,   leafCommand
              "text"
              "Render a Dhall expression that evaluates to a Text literal"
            ⫽ { options = [ fileOpt ] }
          ]
      }
    : Command (Command Void)