Class: Ronin::Core::CLI::CommandShell::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/core/cli/command_shell/command.rb

Overview

Represents a defined command within a Ronin::Core::CLI::CommandShell class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, method_name: name, usage: nil, completions: nil, summary:, help: summary) ⇒ Command

Initializes a command value object.



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/ronin/core/cli/command_shell/command.rb', line 82

def initialize(name, method_name: name,
                     usage:       nil,
                     completions: nil,
                     summary:     ,
                     help:        summary)
  @name        = name
  @method_name = method_name
  @usage       = usage
  @summary     = summary
  @help        = help
  @completions = completions
end

Instance Attribute Details

#completionsArray<String>, ... (readonly)

Possible tab completion values for the command's arguments.



48
49
50
# File 'lib/ronin/core/cli/command_shell/command.rb', line 48

def completions
  @completions
end

#helpString (readonly)

The command's multi-line help output.



58
59
60
# File 'lib/ronin/core/cli/command_shell/command.rb', line 58

def help
  @help
end

#method_nameSymbol (readonly)

The command's method name.



38
39
40
# File 'lib/ronin/core/cli/command_shell/command.rb', line 38

def method_name
  @method_name
end

#nameSymbol (readonly)

The command's name.



33
34
35
# File 'lib/ronin/core/cli/command_shell/command.rb', line 33

def name
  @name
end

#summaryString (readonly)

The command's one-line summary.



53
54
55
# File 'lib/ronin/core/cli/command_shell/command.rb', line 53

def summary
  @summary
end

#usageString? (readonly)

The usage string for the command's arguments.



43
44
45
# File 'lib/ronin/core/cli/command_shell/command.rb', line 43

def usage
  @usage
end

Instance Method Details

#to_sString

Converts the command to a String.



101
102
103
104
105
106
107
# File 'lib/ronin/core/cli/command_shell/command.rb', line 101

def to_s
  if @usage
    "#{@name} #{@usage}"
  else
    @name.to_s
  end
end