Class: Matt::Command
Instance Attribute Summary collapse
Instance Method Summary
collapse
#debug, #info, #puts_err, #puts_out, #stderr, #stdout
Constructor Details
#initialize {|_self| ... } ⇒ Command
Returns a new instance of Command.
40
41
42
43
44
|
# File 'lib/matt/command.rb', line 40
def initialize
@output_format = :csv
@to = nil
yield(self) if block_given?
end
|
Instance Attribute Details
#exitcode ⇒ Object
Returns the value of attribute exitcode.
36
37
38
|
# File 'lib/matt/command.rb', line 36
def exitcode
@exitcode
end
|
Returns the value of attribute output_format.
37
38
39
|
# File 'lib/matt/command.rb', line 37
def output_format
@output_format
end
|
#to ⇒ Object
Returns the value of attribute to.
38
39
40
|
# File 'lib/matt/command.rb', line 38
def to
@to
end
|
Instance Method Details
#call(argv) ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/matt/command.rb', line 69
def call(argv)
ok = false
catch :abort do
parse_argv(argv)
_call(argv)
ok = true
end
self.exitcode = ok ? 0 : 1
end
|
#configuration ⇒ Object
51
52
53
54
|
# File 'lib/matt/command.rb', line 51
def configuration
return @configuration if @configuration
self.configuration = Configuration.new(Path.pwd)
end
|
#configuration=(c) ⇒ Object
56
57
58
59
|
# File 'lib/matt/command.rb', line 56
def configuration=(c)
@on_configuration.call(c) if @on_configuration
@configuration = c
end
|
#has_configuration? ⇒ Boolean
61
62
63
|
# File 'lib/matt/command.rb', line 61
def has_configuration?
!!@configuration
end
|
#on_configuration(&bl) ⇒ Object
46
47
48
49
|
# File 'lib/matt/command.rb', line 46
def on_configuration(&bl)
@on_configuration = bl
self
end
|
#parse_argv(argv) ⇒ Object
65
66
67
|
# File 'lib/matt/command.rb', line 65
def parse_argv(argv)
opt_parser.parse!(argv)
end
|