Module: Acclimate::CliHelper::ClassMethods

Defined in:
lib/acclimate/cli_helper.rb

Instance Method Summary collapse

Instance Method Details

#handle_argument_error(command, error, _, __) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/acclimate/cli_helper.rb', line 29

def handle_argument_error( command, error, _, __ )
  method = "handle_argument_error_for_#{command.name}"

  if respond_to?( method )
    send( method, command, error )
  else
    handle_argument_error_default( command, error )
  end
end

#handle_argument_error_default(command, error) ⇒ Object



39
40
41
42
43
44
# File 'lib/acclimate/cli_helper.rb', line 39

def handle_argument_error_default( command, error )
  $stdout.puts "Incorrect usage of command: #{command.name}"
  $stdout.puts "  #{error.message}", ''
  $stdout.puts "For correct usage:"
  $stdout.puts "  acclimate help #{command.name}"
end

#handle_no_command_error(name) ⇒ Object



46
47
48
# File 'lib/acclimate/cli_helper.rb', line 46

def handle_no_command_error( name )
  $stdout.puts "Unrecognized command: #{name}"
end