Class: Bow::Application
- Inherits:
-
Object
- Object
- Bow::Application
- Defined in:
- lib/bow/application.rb
Constant Summary collapse
- BANNER =
'Usage: bow command arguments [options]'.freeze
- COLUMN_WIDTH =
32- EMPTY_COLUMN =
(' ' * COLUMN_WIDTH).freeze
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #config ⇒ Object
- #debug? ⇒ Boolean
-
#initialize(argv) ⇒ Application
constructor
A new instance of Application.
-
#inventory ⇒ Object
rubocop:enable Lint/ShadowingOuterLocalVariable.
-
#run ⇒ Object
rubocop:disable Lint/ShadowingOuterLocalVariable.
- #ssh_helper(host) ⇒ Object
- #targets(user) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Application
Returns a new instance of Application.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bow/application.rb', line 11 def initialize(argv) = { user: 'root', group: 'all', inventory: 'hosts.json' } @argv = argv.dup @ssh_helpers = {} @debug = false end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
9 10 11 |
# File 'lib/bow/application.rb', line 9 def argv @argv end |
#debug ⇒ Object
Returns the value of attribute debug.
9 10 11 |
# File 'lib/bow/application.rb', line 9 def debug @debug end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/bow/application.rb', line 9 def end |
Instance Method Details
#config ⇒ Object
40 41 42 |
# File 'lib/bow/application.rb', line 40 def config Config end |
#debug? ⇒ Boolean
53 54 55 |
# File 'lib/bow/application.rb', line 53 def debug? !!@debug end |
#inventory ⇒ Object
rubocop:enable Lint/ShadowingOuterLocalVariable
34 35 36 37 38 |
# File 'lib/bow/application.rb', line 34 def inventory return @inventory if @inventory @inventory ||= Inventory.new @inventory.ensure! end |
#run ⇒ Object
rubocop:disable Lint/ShadowingOuterLocalVariable
23 24 25 26 27 28 29 30 31 |
# File 'lib/bow/application.rb', line 23 def run opts = OptionParser.new do |opts| opts. = .parse(opts) end opts.parse!(argv) command = parse_arguments(opts) command.run end |
#ssh_helper(host) ⇒ Object
44 45 46 47 |
# File 'lib/bow/application.rb', line 44 def ssh_helper(host) conn = host.conn @ssh_helpers[conn] ||= SshHelper.new(conn, self) end |
#targets(user) ⇒ Object
49 50 51 |
# File 'lib/bow/application.rb', line 49 def targets(user) @targets ||= Targets.new(inventory.targetfile, user) end |