Class: VagrantPlugins::Rimu::Commands::Root
- Inherits:
-
Object
- Object
- VagrantPlugins::Rimu::Commands::Root
- Defined in:
- lib/vagrant-rimu/commands/root.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Root
constructor
A new instance of Root.
- #usage ⇒ Object
Constructor Details
#initialize(argv, env) ⇒ Root
Returns a new instance of Root.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-rimu/commands/root.rb', line 17 def initialize(argv, env) @env = env @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv) @commands = Vagrant::Registry.new COMMANDS.each do |cmd| @commands.register(cmd[:name]) do require_relative cmd[:file] Commands.const_get(cmd[:clazz]) end end super(argv, env) end |
Class Method Details
.synopsis ⇒ Object
13 14 15 |
# File 'lib/vagrant-rimu/commands/root.rb', line 13 def self.synopsis I18n.t('vagrant_rimu.commands.root_synopsis') end |
Instance Method Details
#execute ⇒ Object
32 33 34 35 36 |
# File 'lib/vagrant-rimu/commands/root.rb', line 32 def execute command_class = @commands.get(@sub_command.to_sym) if @sub_command return usage unless command_class && @sub_command command_class.new(@sub_args, @env).execute(@sub_command) end |
#usage ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/vagrant-rimu/commands/root.rb', line 38 def usage @env.ui.info I18n.t('vagrant_rimu.commands.root_usage') @env.ui.info '' @env.ui.info I18n.t('vagrant_rimu.commands.available_subcommands') @commands.each do |key, value| @env.ui.info " #{key.to_s.ljust(20)} #{value.synopsis}" end @env.ui.info '' end |