Class: VagrantPlugins::Openstack::Command::Main
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::Command::Main
- Defined in:
- lib/vagrant-openstack-provider/command/main.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Main
constructor
A new instance of Main.
- #usage ⇒ Object
Constructor Details
#initialize(argv, env) ⇒ Main
Returns a new instance of Main.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-openstack-provider/command/main.rb', line 19 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] Command.const_get(cmd[:clazz]) end end super(argv, env) end |
Class Method Details
.synopsis ⇒ Object
15 16 17 |
# File 'lib/vagrant-openstack-provider/command/main.rb', line 15 def self.synopsis I18n.t('vagrant_openstack.command.main_synopsis') end |
Instance Method Details
#execute ⇒ Object
34 35 36 37 38 |
# File 'lib/vagrant-openstack-provider/command/main.rb', line 34 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
40 41 42 43 44 45 46 47 48 |
# File 'lib/vagrant-openstack-provider/command/main.rb', line 40 def usage @env.ui.info I18n.t('vagrant_openstack.command.main_usage') @env.ui.info '' @env.ui.info I18n.t('vagrant_openstack.command.available_subcommands') @commands.each do |key, value| @env.ui.info " #{key.to_s.ljust(20)} #{value.synopsis}" end @env.ui.info '' end |