abstract class LuckyTask::Task
- LuckyTask::Task
- Reference
- Object
Defined in:
lucky_task/task.crInstance Method Summary
Macro Summary
-
arg(arg_name, description, shortcut = nil, optional = false, format = nil, example = nil)
Creates a method of
arg_namethat returns the value passed in from the CLI. -
float64(arg_name, description, shortcut = nil, default = nil)
Creates a method of
arg_namewhere the return value is an Float64. -
help_message(help_text)
Customize your help message with the provided
help_text -
int32(arg_name, description, shortcut = nil, default = nil)
Creates a method of
arg_namewhere the return value is an Int32. -
name(name_text)
Renames the task name for CLI use
-
positional_arg(arg_name, description, to_end = false, format = nil, example = nil)
Creates a method of
arg_namethat returns the value passed in from the CLI. -
summary(summary_text)
The general description of what this task does
-
switch(arg_name, description, shortcut = nil)
Creates a method of
arg_namewhere the return value is boolean.
Instance Method Detail
Macro Detail
Creates a method of arg_name that returns the value passed in from the CLI.
The CLI arg is specified by the --arg_name=VALUE flag.
arg_name: String - The name of the argumentdescription: String - The help text description for this optionshorcut: String - An optional short flag (e.g. -a VALUE)optional: Bool - When false, raise exception if this arg is not passedformat: Regex - The format you expect the args to matchexample: String - An example string that matches the givenformat
Creates a method of arg_name where the return value is an Float64.
If the flag --arg_name is passed, the result is the value passed, otherwise is set to
the specified default, or 0.0 when not specified.
arg_name: String - The name of the argumentdescription: String - The help text description for this optionshorcut: String - An optional short flag (e.g.-a)default: Float64 - An optional default value (0.0is default when omittted)
Example: float64 :threshold, "(0.1, 3.14, -5.1, etc.)", shortcut: "-t", default: 2.0
Customize your help message with the provided help_text
class KeyGen < LuckyTask::Task
summary "Generate a new key"
help_message "Call lucky key_gen to generate a new key"
# other methods, etc.
end
Creates a method of arg_name where the return value is an Int32.
If the flag --arg_name is passed, the result is the value passed, otherwise is set to
the specified default, or 0 when not specified.
arg_name: String - The name of the argumentdescription: String - The help text description for this optionshorcut: String - An optional short flag (e.g.-a)default: Int32 - An optional default value (0is default when omittted)
Example: int32 :limit, "limit (1000, 10_000, etc.)", shortcut: "-l", default: 1_000
Renames the task name for CLI use
By default the task name is derived from the full module and class name. However if that task name is not desired, a custom one can be set.
class Dev::Prime < LuckyTask::Task
# Would be "dev.prime" by default, but we want to set it to "dev.setup":
task_name "dev.setup"
summary "Seed the development database with example data"
# other methods, etc.
end
Creates a method of arg_name that returns the value passed in from the CLI.
The CLI arg position is based on the order in which positional_arg is specified
with the first call being position 0, and so on.
If your arg takes more than one value, you can set to_end to true to capture all
args from this position to the end. This will make your arg_name method return Array(String).
arg_name: String - The name of the argumentdescription: String - The help text description for this optionto_end: Bool - Capture all args from this position to the end.format: Regex - The format you expect the args to matchexample: String - An example string that matches the givenformat
The general description of what this task does
This is used in the help_text when a help flag is passed to the task through the CLI
Creates a method of arg_name where the return value is boolean.
If the flag --arg_name is passed, the value is true.
arg_name: String - The name of the argumentdescription: String - The help text description for this optionshorcut: String - An optional short flag (e.g.-a)