Sha256: 50079954c4ec4ef6696f2ab58b6ccdd3cd574d1d415658e7f4bf631bdafc05ff
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
module VagrantPlugins module Openstack module Command COMMANDS = [ { name: :'image-list', file: 'image_list' , clazz: 'ImageList' }, { name: :'flavor-list', file: 'flavor_list', clazz: 'FlavorList' }, { name: :'network-list', file: 'network_list', clazz: 'NetworkList' }, { name: :'floatingip-list', file: 'floatingip_list', clazz: 'FloatingIpList' } ] class Main < Vagrant.plugin('2', :command) def self.synopsis Openstack.init_i18n I18n.t('vagrant_openstack.command.main_synopsis') end 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 def execute Openstack.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 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 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems