Class: UltraCommandLine::Commands::SubCommand

Inherits:
Object
  • Object
show all
Extended by:
Factory
Includes:
CommandLineParser, HelpFormatter, Validation, Utils::ErrorPropagation
Defined in:
lib/ultra_command_line/commands/sub_command.rb

Constant Summary

Constants included from Factory

Factory::DEFAULT_BANNER

Constants included from HelpFormatter

HelpFormatter::DEFAULT_SEPARATOR_FILLER, HelpFormatter::DEFAULT_SEPARATOR_WIDTH, HelpFormatter::DEFAULT_TITLE

Constants included from Utils::ErrorPropagation

Utils::ErrorPropagation::DEFAULT_ERROR_MESSAGE

Instance Attribute Summary collapse

Attributes included from HelpFormatter

#separator_filler, #separator_width

Instance Method Summary collapse

Methods included from Factory

from_hash

Methods included from Utils::YamlFactory

#from_yaml, #from_yaml_file

Methods included from CommandLineParser

#extra_arguments, #params_hash

Methods included from HelpFormatter

#help, #title

Methods included from Validation

#valid?

Constructor Details

#initialize(manager, name = '', banner = UltraCommandLine::Commands::Factory::DEFAULT_BANNER, options: []) ⇒ SubCommand

Returns a new instance of SubCommand.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ultra_command_line/commands/sub_command.rb', line 25

def initialize(manager,
               name = '',
               banner = UltraCommandLine::Commands::Factory::DEFAULT_BANNER,
               options: [])
  @manager = manager
  @name = name
  if name.empty?
    class << self; include UltraCommandLine::Commands::MainCommand; end
  end
  self.banner = banner
  @options = options
  @aliases = [self.name]
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



22
23
24
# File 'lib/ultra_command_line/commands/sub_command.rb', line 22

def aliases
  @aliases
end

Returns the value of attribute banner.



23
24
25
# File 'lib/ultra_command_line/commands/sub_command.rb', line 23

def banner
  @banner
end

#managerObject

Returns the value of attribute manager.



22
23
24
# File 'lib/ultra_command_line/commands/sub_command.rb', line 22

def manager
  @manager
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/ultra_command_line/commands/sub_command.rb', line 22

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



22
23
24
# File 'lib/ultra_command_line/commands/sub_command.rb', line 22

def options
  @options
end

Instance Method Details

#cmd_line_argsObject



43
44
45
# File 'lib/ultra_command_line/commands/sub_command.rb', line 43

def cmd_line_args
  self_view_of_manager_cmd_line_args
end

#root_command?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ultra_command_line/commands/sub_command.rb', line 39

def root_command?
  singleton_class.ancestors.include? UltraCommandLine::Commands::MainCommand
end