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
Constants
pub const default_pretty_help: PrettyHelp = PrettyHelp(
usage: ["182", "255", "234"],
flags: ["255", "175", "243"],
subcommands: ["252", "226", "174"],
)
Default pretty help heading colouring mint colour for usage pink colour for flags buttercup colour for subcommands
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 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