Class: VagrantPlugins::Deltacloud::Command::Main
- Inherits:
-
Object
- Object
- VagrantPlugins::Deltacloud::Command::Main
- Defined in:
- lib/vagrant-deltacloud-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-deltacloud-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
14 15 16 17 |
# File 'lib/vagrant-deltacloud-provider/command/main.rb', line 14 def self.synopsis Deltacloud.init_i18n I18n.t('vagrant_deltacloud.command.main_synopsis') end |
Instance Method Details
#execute ⇒ Object
34 35 36 37 38 39 |
# File 'lib/vagrant-deltacloud-provider/command/main.rb', line 34 def execute Deltacloud.init_i18n 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
41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-deltacloud-provider/command/main.rb', line 41 def usage @env.ui.info I18n.t('vagrant_deltacloud.command.main_usage') @env.ui.info '' @env.ui.info I18n.t('vagrant_deltacloud.command.available_subcommands') @commands.each do |key, value| @env.ui.info " #{key.to_s.ljust(20)} #{value.synopsis}" end @env.ui.info '' end |