Class: VCLog::CLI::Abstract
- Inherits:
-
Object
- Object
- VCLog::CLI::Abstract
show all
- Defined in:
- lib/vclog/cli/abstract.rb
Overview
Abstract base class for all command classes.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
40
41
42
|
# File 'lib/vclog/cli/abstract.rb', line 40
def initialize
@options = {}
end
|
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
86
87
88
|
# File 'lib/vclog/cli/abstract.rb', line 86
def arguments
@arguments
end
|
Class Method Details
.inherited(subclass) ⇒ Object
30
31
32
|
# File 'lib/vclog/cli/abstract.rb', line 30
def self.inherited(subclass)
CLI.register << subclass
end
|
.run(argv) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/vclog/cli/abstract.rb', line 18
def self.run(argv)
new.run(argv)
rescue => err
if $DEBUG
raise err
else
puts err.message
exit -1
end
end
|
.terms ⇒ Object
35
36
37
|
# File 'lib/vclog/cli/abstract.rb', line 35
def self.terms
[name.split('::').last.downcase]
end
|
Instance Method Details
#options ⇒ Object
45
46
47
|
# File 'lib/vclog/cli/abstract.rb', line 45
def options
@options
end
|
#parser(&block) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/vclog/cli/abstract.rb', line 50
def parser(&block)
parser = OptionParser.new(&block)
parser.separator " "
parser.separator "SYSTEM OPTIONS:"
parser.on('--debug', 'show debugging information') do
$DEBUG = true
end
parser.on('--help' , '-h', 'display this help information') do
puts parser
exit
end
parser
end
|
#repo ⇒ Object
81
82
83
|
# File 'lib/vclog/cli/abstract.rb', line 81
def repo
@repo
end
|
#run(argv = nil) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/vclog/cli/abstract.rb', line 66
def run(argv=nil)
argv ||= ARGV.dup
parser.parse!(argv)
@arguments = argv
root = Dir.pwd
@repo = VCLog::Repo.new(root, options)
execute
end
|