cosmo_cli

Types

Command is a struct that represents a command in the CLI.

pub opaque type Command

Flag is a struct that represents a command line flag.

pub opaque type Flag

Values

pub fn get_flag_bool(
  command: Command,
  flag_name: String,
) -> Result(Bool, String)

get_flag_bool returns the value of a boolean flag. the flag key must be the long name with double-hyphen.

pub fn get_flag_int(
  command: Command,
  flag_name: String,
) -> Result(Int, String)

get_flag_int returns the value of an int flag. the flag key must be the long name with double-hyphen.

pub fn get_flag_string(
  command: Command,
  flag_name: String,
) -> Result(String, String)

get_flag_string returns the value of a string flag. the flag key must be the long name with double-hyphen.

pub fn main() -> Nil
pub fn new_command(
  name name: String,
  run run: fn(Command) -> Result(Nil, String),
  option_fns option_fns: List(fn(Command) -> Command),
) -> Command

new_command creates a new command with the given name, run function, and options.

pub fn new_flag_bool(
  long_name: String,
  option_fns: List(fn(Flag) -> Flag),
) -> Flag

new_flag_bool creates a new boolean flag with the given long name and options.

pub fn new_flag_int(
  long_name: String,
  option_fns: List(fn(Flag) -> Flag),
) -> Flag

new_flag_int creates a new int flag with the given long name and options.

pub fn new_flag_string(
  long_name: String,
  option_fns: List(fn(Flag) -> Flag),
) -> Flag

new_flag_string creates a new string flag with the given long name and options.

pub fn run(
  command command: Command,
  args args: List(String),
) -> Result(Nil, String)

run executes the root command with the given arguments. It can be called with os argv that has the command name as the first argument.

pub fn run_with_argv(
  command command: Command,
) -> Result(Nil, String)
pub fn with_command_flags(
  flags: List(Flag),
) -> fn(Command) -> Command

with_command_sub_commands sets the sub commands for a command.

pub fn with_command_long(long: String) -> fn(Command) -> Command

with_command_long sets the long description for a command.

pub fn with_command_short(
  short: String,
) -> fn(Command) -> Command

with_command_short sets the short description for a command.

pub fn with_command_sub_commands(
  sub_commands: Dict(String, Command),
) -> fn(Command) -> Command

with_command_run sets the run function for a command.

pub fn with_flag_default_bool(default: Bool) -> fn(Flag) -> Flag

with_flag_default_bool sets the default value for a boolean flag.

pub fn with_flag_default_int(default: Int) -> fn(Flag) -> Flag

with_flag_default_int sets the default value for an int flag.

pub fn with_flag_default_string(
  default: String,
) -> fn(Flag) -> Flag

with_flag_default_string sets the default value for a string flag.

pub fn with_flag_description(
  description: String,
) -> fn(Flag) -> Flag

with_flag_description sets the description for a flag.

pub fn with_flag_short(short: String) -> fn(Flag) -> Flag

with_flag_long sets the long name for a flag.

Search Document