lux/cli

Types

CLI

A command-line interface parser.

(type: (CLI a)
  (-> (lux;List lux;Text) (lux/data/error;Error [(lux;List lux;Text) a])))

Macros

program:

## Defines the entry-point to a program (similar to the "main" function/method in other programming languages).
## Can take a list of all the input parameters to the program, or can destructure them using CLI-option combinators from the lux/cli module.
(program: all-args
  (do Monad<IO>
    [foo init-program
     bar (do-something all-args)]
    (wrap [])))

(program: (name)
  (io (log! (Text/append "Hello, " name))))

(program: ([config config^])
  (do Monad<IO>
    [data (init-program config)]
    (do-something data)))

Structs

Applicative<CLI>

(lux/control/applicative;Applicative CLI)

Functor<CLI>

(lux/control/functor;Functor CLI)

Monad<CLI>

(lux/control/monad;Monad CLI)

Values

(alt optL optR)

Heterogeneous alternative combinator.

(All [a b] (-> (CLI a) (CLI b) (CLI (| a b))))

any

Just returns the next input without applying any logic.

(CLI lux;Text)

(assert message test)

Fails with the given message if the test is false.

(-> lux;Text lux;Bool (CLI lux;Unit))

(either pl pr)

Homogeneous alternative combinator.

(All [a] (-> (CLI a) (CLI a) (CLI a)))

end

Ensures there are no more inputs.

(CLI lux;Unit)

(flag names)

Checks that a given flag (with multiple possible names) is set.

(-> (lux;List lux;Text) (CLI lux;Bool))

(many opt)

1-or-more combinator.

(All [a] (-> (CLI a) (CLI (lux;List a))))

(not opt)

The opposite of the given CLI.

(All [a] (-> (CLI a) (CLI lux;Unit)))

(opt opt)

Optionality combinator.

(All [a] (-> (CLI a) (CLI (lux;Maybe a))))

(option names)

Checks that a given option (with multiple possible names) has a value.

(-> (lux;List lux;Text) (CLI lux;Text))

(parse parser)

Parses the next input with a parsing function.

(All [a] (-> (-> lux;Text (lux/data/error;Error a)) (CLI a)))

(run opt inputs)

(All [a] (-> (CLI a) (lux;List lux;Text) (lux/data/error;Error a)))

(seq optL optR)

Sequencing combinator.

(All [a b] (-> (CLI a) (CLI b) (CLI [a b])))

(some opt)

0-or-more combinator.

(All [a] (-> (CLI a) (CLI (lux;List a))))