Class: Clin::Command

Inherits:
Object
  • Object
show all
Includes:
Clin::CommandMixin::Core, Clin::CommandMixin::Dispatcher, Clin::CommandMixin::Options
Defined in:
lib/clin/command.rb

Overview

Clin Command

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Command

Returns a new instance of Command.



28
29
30
31
32
# File 'lib/clin/command.rb', line 28

def initialize(params = {})
  @params = params
  @shell = Clin::Shell.new
  self.class.execute_general_options(params)
end

Instance Attribute Details

#paramsObject

Contains the parameters



22
23
24
# File 'lib/clin/command.rb', line 22

def params
  @params
end

#shellObject

Contains a shell object for user interaction in the command

See Also:



26
27
28
# File 'lib/clin/command.rb', line 26

def shell
  @shell
end

Class Method Details

.parse(argv = ARGV, fallback_help: true) ⇒ Object

Parse the command and initialize the command object with the parsed options

Parameters:

  • argv (Array|String) (defaults to: ARGV)

    command line to parse.



16
17
18
19
# File 'lib/clin/command.rb', line 16

def self.parse(argv = ARGV, fallback_help: true)
  parser = Clin::CommandParser.new(self, argv, fallback_help: fallback_help)
  parser.parse
end