listen.dh 1.13 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1 2 3 4 5 6
let values = ../resources/package.dh

let types = ../resources/types.dh

let argotypes = ./types.dh

Valentin Reis's avatar
Valentin Reis committed
7
let basicCommand = ./basicCommand.dh
Valentin Reis's avatar
Valentin Reis committed
8 9 10 11 12

let defaultMkListen =
        λ(containerName : Text)
      →   { attr =
              "performance"
Valentin Reis's avatar
Valentin Reis committed
13
          , doFilter =
Valentin Reis's avatar
Valentin Reis committed
14 15 16 17
              False
          , filter =
              ","
          , containerName =
Valentin Reis's avatar
Valentin Reis committed
18
              containerName
Valentin Reis's avatar
Valentin Reis committed
19 20 21 22 23 24 25 26 27 28 29 30 31
          }
        : argotypes.MkListen

let listen =
        λ(a : argotypes.MkListen)
      →     basicCommand
            { name =
                "nrm"
            , outprefix =
                "nrmlisten"
            , outavoids =
                [] : List Text
            , outwants =
Valentin Reis's avatar
Valentin Reis committed
32
                if a.doFilter then [ a.filter ] else [] : List Text
Valentin Reis's avatar
Valentin Reis committed
33 34 35 36
            }
          ⫽ { args = [ "listen", "-u", a.containerName, "--filter", a.filter ] }
        : types.Cmd

Valentin Reis's avatar
Valentin Reis committed
37 38
let default =
        λ(containerName : Text)
Valentin Reis's avatar
Valentin Reis committed
39
      → listen (defaultMkListen containerName) : types.Cmd
Valentin Reis's avatar
Valentin Reis committed
40

Valentin Reis's avatar
Valentin Reis committed
41
in  { defarg =
Valentin Reis's avatar
Valentin Reis committed
42
        defaultMkListen : Text → argotypes.MkListen
Valentin Reis's avatar
Valentin Reis committed
43 44 45
    , mk =
        listen : argotypes.MkListen → types.Cmd
    , default =
Valentin Reis's avatar
Valentin Reis committed
46
        default : Text → types.Cmd
Valentin Reis's avatar
Valentin Reis committed
47
    }