Module: Climate

Defined in:
lib/climate.rb,
lib/climate/help.rb,
lib/climate/errors.rb,
lib/climate/option.rb,
lib/climate/parser.rb,
lib/climate/script.rb,
lib/climate/command.rb,
lib/climate/version.rb,
lib/climate/argument.rb

Defined Under Namespace

Modules: ParsingMethods, Script Classes: Argument, Command, CommandError, DefinitionError, Error, ExitException, Help, HelpNeeded, MissingArgumentError, Option, Parser, UnexpectedArgumentError, UnknownCommandError

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



32
33
34
35
36
# File 'lib/climate.rb', line 32

def self.print_usage(command_class, options={})
  help = Help.new(command_class)

  help.print
end

.with_standard_exception_handling(&block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/climate.rb', line 4

def self.with_standard_exception_handling(&block)
  begin
    yield
  rescue ExitException => e
    $stderr.puts(e.message)
    exit(e.exit_code)
  rescue HelpNeeded => e
    print_usage(e.command_class)
    exit(0)
  rescue UnexpectedArgumentError => e
    $stderr.puts("Unknown argument: #{e.message}")
    print_usage(e.command_class)
    exit(1)
  rescue UnknownCommandError => e
    $stderr.puts("Unknown command: #{e.message}")
    print_usage(e.command_class)
    exit(1)
  rescue MissingArgumentError => e
    $stderr.puts("Missing argument: #{e.message}")
    print_usage(e.command_class)
    exit(1)
  rescue => e
    $stderr.puts("Unexpected error: #{e.class.name} - #{e.message}")
    $stderr.puts(e.backtrace)
    exit(2)
  end
end

Instance Method Details

#run(&block) ⇒ Object



38
39
# File 'lib/climate.rb', line 38

def run(&block)
end