abstract class LuckyCli::Task

Defined in:

lucky_cli/task.cr

Instance Method Summary

Macro Summary

Instance Method Detail

abstract def call #

[View source]
abstract def summary #

[View source]

Macro Detail

macro arg(arg_name, description, shortcut = nil, optional = false, format = nil) #

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 argument
  • description : String - The help text description for this option
  • shorcut : String - An optional short flag (e.g. -a VALUE)
  • optional : Bool - When false, raise exception if this arg is not passed
  • format : Regex - The format you expect the args to match

[View source]
macro banner(banner_text) #

[View source]
macro name(name_text) #

Sets a custom title for the task

By default the name is derived from the full module and class name. However if that name is not desired, a custom one can be set.

class Dev::Prime < LuckyCli::Task
  # Would be "dev.prime" by default, but we want to set it to "dev.setup":
  name "dev.setup"
  summary "Seed the development database with example data"

  # other methods, etc.
end

[View source]
macro positional_arg(arg_name, description, to_end = false, format = nil) #

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 argument
  • description : String - The help text description for this option
  • to_end : Bool - Capture all args from this position to the end.
  • format : Regex - The format you expect the args to match

[View source]
macro summary(summary_text) #

[View source]
macro switch(arg_name, description, shortcut = nil) #

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 argument
  • description : String - The help text description for this option
  • shorcut : String - An optional short flag (e.g. -a)

[View source]