Class: Ronin::UI::CommandLine::Command

  • Thor
    • Ronin::UI::CommandLine::Command

Included Modules

Thor::Actions, Ronin::UI::Output::Helpers

Constructor Summary

public initialize(arguments = [], options = {}, config = {})

Creates a new Command object.

Meta Tags

Parameters:

[Array] arguments

Command-line arguments.

[Hash] options

Additional command-line options.

[Hash] config

Additional configuration.

[View source]


49
50
51
52
53
# File 'lib/ronin/ui/command_line/command.rb', line 49

def initialize(arguments=[],options={},config={})
  @indent = 0

  super(arguments,options,config)
end

Public Visibility

Public Class Method Summary

start(arguments = ARGV, config = {})

Public Instance Method Summary

#default(*arguments)

Default method to call after the options have been parsed.

#help

Prints the help information for the command and exists.

Public Class Method Details

start

public start(arguments = ARGV, config = {})
[View source]


55
56
57
58
59
60
61
# File 'lib/ronin/ui/command_line/command.rb', line 55

def self.start(arguments=ARGV,config={})
  unless map[arguments.first.to_s]
    arguments = [default_task] + arguments
  end

  super(arguments,config)
end

Public Instance Method Details

default

public default(*arguments)

Default method to call after the options have been parsed.

[View source]


87
88
# File 'lib/ronin/ui/command_line/command.rb', line 87

def default(*arguments)
end

help

public help

Prints the help information for the command and exists.

[View source]


95
96
97
98
99
100
101
102
103
# File 'lib/ronin/ui/command_line/command.rb', line 95

def help
  self.class.help(
    shell, 
    self.class.default_task,
    :short => false,
    :ident => 2,
    :namespace => false
  )
end

Protected Visibility

Protected Instance Method Summary

#indent(n = 2, &block)

Increases the indentation out output temporarily.

Returns: nil

#name

Returns the name of the command.

#print_array(array, options = {})

Prints a given Array.

Returns: nil

#print_hash(hash, options = {})

Prints a given Hash.

Returns: nil

#print_title(title)

Prints a given title.

#puts(*messages)

Print the given messages with indentation.

Protected Instance Methods Included from Ronin::UI::Output::Helpers

print_debug, print_error, print_info, print_warning

Protected Instance Method Details

indent

protected nil indent(n = 2, &block)

Increases the indentation out output temporarily.

Meta Tags

Parameters:

[Integer] n

The number of spaces to increase the indentation by.

Yields:

[Object]
The block will be called after the indentation has been increased. After the block has returned, the indentation will be returned to normal.

Returns:

[nil]
[View source]


127
128
129
130
131
132
133
134
# File 'lib/ronin/ui/command_line/command.rb', line 127

def indent(n=2,&block)
  @indent += n

  block.call()

  @indent -= n
  return nil
end

name

protected name

Returns the name of the command.

[View source]


110
111
112
# File 'lib/ronin/ui/command_line/command.rb', line 110

def name
  self.class.name.split('::').last.snake_case
end

print_array

print_hash

print_title

puts

protected puts(*messages)

Print the given messages with indentation.

Meta Tags

Parameters:

[Array] messages

The messages to print, one per-line.

[View source]


142
143
144
# File 'lib/ronin/ui/command_line/command.rb', line 142

def puts(*messages)
  super(*(messages.map { |mesg| (' ' * @indent) + mesg.to_s }))
end
Generated on Friday, September 25 2009 at 02:57:05 PM by YARD 0.2.3.5 (ruby-1.8.6).