Class: JamesBond::Core::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/james_bond/core/command.rb

Constant Summary collapse

RESERVED_COMMANDS =
["env", "run", "server", "test", "deploy", "console"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv:, env:) ⇒ Command

Returns a new instance of Command.



14
15
16
17
18
19
20
21
# File 'lib/james_bond/core/command.rb', line 14

def initialize(argv:, env:)
  @argv             = argv
  @user_command     = argv.join(" ")
  @main_command     = argv.first
  @raw_arguments    = argv.drop(1)
  @arguments_string = @raw_arguments.join(" ")
  @env              = env
end

Instance Attribute Details

#arguments_stringObject

Returns the value of attribute arguments_string.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def arguments_string
  @arguments_string
end

#argvObject

Returns the value of attribute argv.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def argv
  @argv
end

#envObject

Returns the value of attribute env.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def env
  @env
end

#main_commandObject

Returns the value of attribute main_command.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def main_command
  @main_command
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def options
  @options
end

#raw_argumentsObject

Returns the value of attribute raw_arguments.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def raw_arguments
  @raw_arguments
end

#user_commandObject

Returns the value of attribute user_command.



6
7
8
# File 'lib/james_bond/core/command.rb', line 6

def user_command
  @user_command
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/james_bond/core/command.rb', line 23

def empty?
  @argv.empty?
end