Title here
Summary here
(let flag (fun (name desc) (...)))
Defines a command line flag
Note: All flags are optional and turned off
name
: how the flag is named, eg “–debug”desc
: what the flag achieves(let value (fun (name desc default) (...)))
Defines a command line value
Note: All values are required and equal to their default value
name
: how the value is named, eg “filename”desc
: what the value is fordefault
: default value for the value(let oneOf (fun (params) (...)))
Creates a group of flags/values/groups where only one of the subgroup has to match
params
: list of flags/values/groups(let group (fun (params) (...)))
Creates a group of flags/values/groups where all of the subgroups have to match
params
: list of flags/values/groups(let parseArgs (fun (args cli) (...)))
Parse a list of arguments given a CLI definition
Note: Recursively visit the CLI to parse the argument list
args
: list of arguments, eg sys:argscli
: cli definition(import std.Cli)
(let command_line
(cli:oneOf [
(cli:flag "--help" "Display an help message")
(cli:flag "--repl" "Start the REPL")
(cli:group [
(cli:flag "-c" "Compile a given file")
(cli:value "file" "Path to the file to run" nil) ])]))
(print (cli:help "miniark" "A mini ArkScript CLI" command_line))
(print (cli:parseArgs ["-c" "path.ark"] command_line))