about summary refs log tree commit diff
path: root/pkgs/profpatsch/dhallsh/main.dhall
blob: abf53032d4d04b8cb727abab805ab1274607c822 (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
let Command = ./Command/type.dhall

let Argument = ./Argument/type.dhall

let Complete = ./Fish/Complete/type.dhall

let argCommandToList
    : Command Argument → List Text
    = ./Command/toList.dhall
      Argument
      (./Argument/toArgList.dhall ./OptionPrinter/newStyle.dhall)

let complete = ./Fish/Complete/default.dhall

let completeToCommand
    : Complete → Command Argument
    = ./Fish/Complete/toCommand.dhall ./OptionPrinter/newStyle.dhall

in  let fishSeenSubcommandFn = "__fish_seen_subcommand_from"

    let fishUseSubcommandFn = "__fish_use_subcommand"

    let fooSubcommand
        : Command Argument
        = completeToCommand
          (   complete { cmd = "abc", description = "this is foo option" }
            ⫽ { condition =
                  Some { cmd = fishUseSubcommandFn, args = [] : List Argument }
              , argument =
                  Some "foo"
              }
          )

    let fooSubcommandBarOption
        : Command Argument
        = completeToCommand
          (   complete { cmd = "abc", description = "will bar the baz" }
            ⫽ { condition =
                  Some
                  { cmd =
                      fishSeenSubcommandFn
                  , args =
                      [ Argument.Plain "foo" ]
                  }
              , long-option =
                  Some "bar"
              , short-option =
                  Some "b"
              }
          )

    in    [ argCommandToList fooSubcommand
          , argCommandToList fooSubcommandBarOption
          , [ "complete", "--do-complete=abc foo -" ]
          ]
        : List (List Text)