Class: VagrantPlugins::AnsibleInventory::Commands::Root
- Inherits:
-
Object
- Object
- VagrantPlugins::AnsibleInventory::Commands::Root
- Defined in:
- lib/vagrant/ansible_inventory/commands/root.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
- #help ⇒ Object
-
#initialize(argv, env) ⇒ Root
constructor
A new instance of Root.
Constructor Details
#initialize(argv, env) ⇒ Root
Returns a new instance of Root.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant/ansible_inventory/commands/root.rb', line 12 def initialize(argv, env) super @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv) @subcommands = Vagrant::Registry.new @subcommands.register(:inventory) do require_relative 'inventory' Inventory end end |
Class Method Details
.synopsis ⇒ Object
8 9 10 |
# File 'lib/vagrant/ansible_inventory/commands/root.rb', line 8 def self.synopsis 'build ansible inventory' end |
Instance Method Details
#execute ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant/ansible_inventory/commands/root.rb', line 25 def execute if @main_args.include?('-h') || @main_args.include?('--help') return help end command_class = @subcommands.get(@sub_command.to_sym) if @sub_command return help if !command_class || !@sub_command @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}") command_class.new(@sub_args, @env).execute end |
#help ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vagrant/ansible_inventory/commands/root.rb', line 37 def help opts = OptionParser.new do |o| o. = 'Usage: vagrant ansible <subcommand> [<options>]' o.separator '' o.separator 'Available subcommands:' keys = [] @subcommands.each { |key, value| keys << key.to_s } keys.sort.each do |key| o.separator " #{key}" end o.separator "" o.separator "For help on any individual subcommand run `vagrant ansible <subcommand> -h`" end @env.ui.info(opts.help, prefix: false) end |