class Fission::Command

Attributes

args[R]

Internal: Returns the Array arguments of the command.

options[R]

Internal: Returns the OpenStruct options of the command.

Public Class Methods

help() click to toggle source

Internal: Helper method to return the help text of a command. This is intended to be used by a command class which inherits from this class. This method will call the 'option_parser' method which must be defined in any class which inherits from this class.

Examples

Fission::Command::Suspend.help

Returns a String of the output parser text.

# File lib/fission/command.rb, line 91
def self.help
  self.new.option_parser.to_s
end
new(args=[]) click to toggle source

Internal: Initializes a new Command with some basic setup. This is intended to be used as a base class for other command classes to inherit from.

args - Array of arguments which will be assigned to the args instance

variable.

Examples

Fission::Command.new ['foo', 'bar']
# File lib/fission/command.rb, line 27
def initialize(args=[])
  ui
  @options = OpenStruct.new
  @args = args
end

Public Instance Methods

command_name(klass=self) click to toggle source

Internal: Helper method to determine the command name of command class. This should only be called against descendants of this class.

xamples:

Fission::Command::SnapshotList.new.command_name
# => 'snapshot list'

Returns the command name as a String.

# File lib/fission/command.rb, line 63
def command_name(klass=self)
  klass.class.name.split('::')[2].
                   gsub(/([a-z\d])([A-Z])/,'\1_\2').
                   gsub('_', ' ').downcase
end
execute() click to toggle source

Internal: Primary method for performing an action within a command.

Examples

command.execute

Returns nothing

# File lib/fission/command.rb, line 40
def execute
  parse_arguments
end
summary() click to toggle source

Internal: Summmary of the command. This is to be implemented by any class which inherits from this class.

Examples

command.summary
# => 'This command does x and y'

Returns a String summary of the command.

# File lib/fission/command.rb, line 77
def summary
  raise NotImplementedError
end
ui() click to toggle source

Internal: Helper method used to delegate UI related methods through.

Examples

command.ui.output 'foo'

Returns a UI instance.

# File lib/fission/command.rb, line 51
def ui
  @ui ||= UI.new
end