Class: GitTree::AbstractCommand
- Inherits:
-
Object
- Object
- GitTree::AbstractCommand
- Includes:
- Logging
- Defined in:
- lib/commands/abstract_command.rb
Overview
Abstract base class for all git-tree commands. It handles common option parsing for verbosity and help.
Direct Known Subclasses
CommitAllCommand, EvarsCommand, ExecCommand, ReplicateCommand, UpdateCommand
Constant Summary
Constants included from Logging
Logging::DEBUG, Logging::NORMAL, Logging::QUIET, Logging::VERBOSE
Class Attribute Summary collapse
-
.allow_empty_args ⇒ Object
Returns the value of attribute allow_empty_args.
Instance Method Summary collapse
-
#initialize(args = ARGV, options: {}) ⇒ AbstractCommand
constructor
A new instance of AbstractCommand.
-
#setup ⇒ Object
Common setup for all commands.
Methods included from Logging
#log, #log_stdout, verbosity, verbosity=
Constructor Details
#initialize(args = ARGV, options: {}) ⇒ AbstractCommand
Returns a new instance of AbstractCommand.
15 16 17 18 19 20 21 22 |
# File 'lib/commands/abstract_command.rb', line 15 def initialize(args = ARGV, options: {}) @args = args @options = @config = GitTree::Config.new # Set initial verbosity from config before anything else happens. # log Logging::VERBOSE, "AbstractCommand#initialize: Setting initial verbosity from config to: #{@config.verbosity}" Logging.verbosity = @config.verbosity end |
Class Attribute Details
.allow_empty_args ⇒ Object
Returns the value of attribute allow_empty_args.
12 13 14 |
# File 'lib/commands/abstract_command.rb', line 12 def allow_empty_args @allow_empty_args end |
Instance Method Details
#setup ⇒ Object
Common setup for all commands. Parses options and sets initial verbosity.
26 27 28 29 30 |
# File 'lib/commands/abstract_command.rb', line 26 def setup # CLI options can override the config verbosity. log Logging::VERBOSE, "AbstractCommand#setup: verbosity before parsing options: #{Logging.verbosity}" (@args) end |