Class: VCLog::CLI::Abstract
- Inherits:
-
Object
- Object
- VCLog::CLI::Abstract
- Defined in:
- lib/vclog/cli/abstract.rb
Overview
Abstract base class for all command classes.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Abstract
constructor
A new instance of Abstract.
- #options ⇒ Object
- #parser(&block) ⇒ Object
-
#repo ⇒ Object
Repo is set in #run.
-
#run(argv = nil) ⇒ Object
Run the command.
Constructor Details
#initialize ⇒ Abstract
Returns a new instance of Abstract.
40 41 42 |
# File 'lib/vclog/cli/abstract.rb', line 40 def initialize @options = {} end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
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. 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 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
Repo is set in #run.
81 82 83 |
# File 'lib/vclog/cli/abstract.rb', line 81 def repo @repo end |