abstract class Cli::CommandBase

Overview

The base of command classes.

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

Direct Known Subclasses

Defined in:

lib/command_base/macros.cr
lib/command_base.cr

Class Method Summary

Instance Method Summary

Macro Summary

Class Method Detail

def self.command_name(value : String) #

Sets the command name.


[View source]
def self.disable_help_on_parsing_error! #

Disables printing a help message when a parsing error occurs.


[View source]
def self.generate_bash_completion #

Generates a bash completion script.


[View source]
def self.generate_zsh_completion(functional : Bool = true) #

Generates a zsh completion script.


[View source]
def self.version(value : String) #

Sets the command version.


[View source]

Instance Method Detail

def args #

Returns option and argument values (an OptionModel instance).

This method is the same as #options.


[View source]
def err #

Returns the :err IO.


[View source]
def error!(message : String? = nil, code : Int32? = nil, help : Bool = false, indent = 2) #

Exits the command with an error status.


[View source]
def exit!(message : String? = nil, error : Bool = false, code : Int32? = nil, help = false, indent = 2) #

Exits the command.


[View source]
def help!(message : String? = nil, error : Bool? = nil, code : Int32? = nil, indent = 2) #

Prints a help message and exits the command.


[View source]
def io #

Returns a named IO container.


[View source]
def nameless_args : Array(String) #

Returns an array of nameless argument values.

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


[View source]
def options #

Returns option and argument values (an OptionModel instance).

This method is the same as #args.


[View source]
def out #

Returns the :out IO.


[View source]
def print(*args) #

Invokes the :out IO'S print method.


[View source]
def puts(*args) #

Invokes the :out IO's puts method.


[View source]
def run #

Runs the command.

This method is an entrypoint for running a command.

Subclasses must override this method.


[View source]
def unparsed_args : Array(String) #

Returns an array of unparsed argument values.

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


[View source]
def version : String #

Returns the command version.


[View source]
def version! #

Prints a version string and exits the command.


[View source]
def version? : String? #

Returns the command version.

Returns nil, if no version is set.


[View source]

Macro Detail

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

Defines a new callback group.

This macro is automatically defined by the Crystal Callback library.


[View source]
macro 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.


[View source]
macro replacer_command(klass) #

Replaces this command with the klass command.


[View source]