class

Cli::CommandBase

Inherits Reference < Object

The base of command classes.

Your application should not directly inherit this class. Instead, use Command or Supercommand.

Class methods

command_name(value : String)

Sets the command name.

Source
disable_help_on_parsing_error!

Disables printing a help message when a parsing error occurs.

Source
generate_bash_completion

Generates a bash completion script.

Source
generate_zsh_completion(functional : Bool = true)

Generates a zsh completion script.

Source
version(value : String)

Sets the command version.

Source

Instance methods

args

Returns option and argument values (an OptionModel instance).

This method is the same as #options.

Source
err

Returns the :err IO.

Source
error!(message : String | Nil = nil, code : Int32 | Nil = nil, help : Bool = false, indent = 2)

Exits the command with an error status.

Source
exit!(message : String | Nil = nil, error : Bool = false, code : Int32 | Nil = nil, help = false, indent = 2)

Exits the command.

Source
help!(message : String | Nil = nil, error : Bool | Nil = nil, code : Int32 | Nil = nil, indent = 2)

Prints a help message and exits the command.

Source
io

Returns a named IO container.

Source
nameless_args

Returns an array of nameless argument values.

This method is a short form of #args.nameless_args.

Source
options

Returns option and argument values (an OptionModel instance).

This method is the same as #args.

Source
out

Returns the :out IO.

Source
puts(*args)

Invokes the :out IO's puts method.

Source
run

Runs the command.

This method is an entrypoint for running a command.

Subclasses must override this method.

Source
unparsed_args

Returns an array of unparsed argument values.

This method is a short form of #args.unparsed_args.

Source
version

Returns the command version.

Source
version!

Prints a version string and exits the command.

Source
version?

Returns the command version.

Returns nil, if no version is set.

Source

Macros

define_callback_group(name, proc_type = ::Proc(::Nil))

Defines a new callback group.

This macro is automatically defined by the Crystal Callback library.

Source
inherit_callback_group(name, proc_type = ::Proc(::Nil))

Inherits an existing callback group that is defined in its ancestor class.

This macro is automatically defined by the Crystal Callback library.

Source
replacer_command(klass)

Replaces this command with the klass command.

Source