Module: Climatic::ConfigLayers::CommandLineManagerBinder

Included in:
CommandLineLayer
Defined in:
lib/climatic/config_layers/command_line_manager_binder.rb

Constant Summary collapse

SUB_COMMANDS_HELP_HEADER =
[
    '',
    '-' * 80,
    ' Following subcommands exist too:',
    ' For more information you can always issue sub_command_name --help...',
    '-' * 80
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#command_line_managerObject

Returns the value of attribute command_line_manager.



14
15
16
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 14

def command_line_manager
  @command_line_manager
end

Instance Method Details

#cmd_line_argsObject



16
17
18
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 16

def cmd_line_args
  command_line_manager.cmd_line_args
end

#cmd_line_args=(args) ⇒ Object



20
21
22
23
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 20

def cmd_line_args=(args)
  command_line_manager.cmd_line_args = args
  reload
end

#extra_parametersObject



25
26
27
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 25

def extra_parameters
  with_selected_command {|c| c.extra_arguments }
end

#helpObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 38

def help
  with_selected_command do |c|
    if c.root_command?
      res = c.help
      sub_commands = command_line_manager.commands.select {|command| not command.root_command?}
      unless sub_commands.empty?
        res.concat SUB_COMMANDS_HELP_HEADER
        sub_commands.sort{|a,b| a.name <=> b.name }.each do |command|
          # command_summary = "#{command.help[0][0,60].tr("\n", ' ')}..."
          res << " * #{command.name}: #{command_summary command}"
        end

      end
      res
    else
      c.help
    end
  end
end

#loadObject Also known as: reload



29
30
31
32
33
34
35
# File 'lib/climatic/config_layers/command_line_manager_binder.rb', line 29

def load
  with_selected_command do |c|
    replace c.params_hash
    @file_name = :none
  end
  self
end