glint
Types
Input type for Runner
.
pub type CommandInput {
CommandInput(args: List(String), flags: FlagMap)
}
Constructors
-
CommandInput(args: List(String), flags: FlagMap)
Config for glint
pub type Config {
Config(pretty_help: Option(PrettyHelp))
}
Constructors
-
Config(pretty_help: Option(PrettyHelp))
Ok type for command execution
pub type Out(a) {
Out(a)
Help(String)
}
Constructors
-
Out(a)
Container for the command return value
-
Help(String)
Container for the generated help string
pub type PrettyHelp {
PrettyHelp(usage: Colour, flags: Colour, subcommands: Colour)
}
Constructors
-
PrettyHelp(usage: Colour, flags: Colour, subcommands: Colour)
Constants
Functions
pub fn add_command(to glint: Glint(a), at path: List(String), do f: fn(
CommandInput,
) -> a, with flags: List(#(String, Contents)), described description: String) -> Glint(
a,
)
Adds a new command to be run at the specified path.
If the path is [], the root command is set with the provided function and flags.
Note: all command paths are sanitized by stripping whitespace and removing any empty string elements.
pub fn add_command_from_stub(to glint: Glint(a), with stub: Stub(
a,
)) -> Glint(a)
Add a command to the root given a stub
pub fn default_pretty_help() -> PrettyHelp
Default pretty help heading colouring mint (r: 182, g: 255, b: 234) colour for usage pink (r: 255, g: 175, b: 243) colour for flags buttercup (r: 252, g: 226, b: 174) colour for subcommands
pub fn execute(glint: Glint(a), args: List(String)) -> Result(
Out(a),
Snag,
)
Determines which command to run and executes it.
Sets any provided flags if necessary.
Each value prefixed with --
is parsed as a flag.
pub fn help_flag() -> String
Function to create the help flag string Exported for testing purposes only
pub fn run(glint: Glint(a), args: List(String)) -> Nil
A wrapper for execute
that discards output and prints any errors
encountered.
pub fn with_config(glint: Glint(a), config: Config) -> Glint(a)
Add the provided config to the existing command tree
pub fn with_global_flags(glint: Glint(a), flags: List(
#(String, Contents),
)) -> Glint(a)
Add global flags to the existing command tree
pub fn with_pretty_help(glint: Glint(a), pretty: PrettyHelp) -> Glint(
a,
)
Enable custom colours for help text headers
For a pre-made colouring use default_pretty_help()
pub fn without_pretty_help(glint: Glint(a)) -> Glint(a)
Disable custom colours for help text headers