Class: VagrantPlugins::Rimu::Commands::AbstractCommand
- Inherits:
-
Object
- Object
- VagrantPlugins::Rimu::Commands::AbstractCommand
- Defined in:
- lib/vagrant-rimu/commands/abstract_command.rb
Direct Known Subclasses
Instance Method Summary collapse
- #before_cmd(_name, _argv, _env) ⇒ Object
- #cmd(_name, _argv, _env) ⇒ Object
- #execute(name) ⇒ Object
-
#initialize(argv, env) ⇒ AbstractCommand
constructor
A new instance of AbstractCommand.
-
#normalize_args(args) ⇒ Object
rubocop:enable Lint/RescueException.
Constructor Details
#initialize(argv, env) ⇒ AbstractCommand
Returns a new instance of AbstractCommand.
7 8 9 10 |
# File 'lib/vagrant-rimu/commands/abstract_command.rb', line 7 def initialize(argv, env) @env = env super(normalize_args(argv), env) end |
Instance Method Details
#before_cmd(_name, _argv, _env) ⇒ Object
38 39 |
# File 'lib/vagrant-rimu/commands/abstract_command.rb', line 38 def before_cmd(_name, _argv, _env) end |
#cmd(_name, _argv, _env) ⇒ Object
41 42 43 |
# File 'lib/vagrant-rimu/commands/abstract_command.rb', line 41 def cmd(_name, _argv, _env) fail 'Command not implemented. \'cmd\' method must be overridden in all subclasses' end |
#execute(name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-rimu/commands/abstract_command.rb', line 12 def execute(name) env = {} with_target_vms(nil, provider: :rimu) do |machine| env[:machine] = machine env[:ui] = @env.ui end before_cmd(name, @argv, env) cmd(name, @argv, env) @env.ui.info('') # rubocop:disable Lint/RescueException rescue Errors::RimuError, SystemExit, Interrupt => e raise e rescue Exception => e puts I18n.t('vagrant_rimu.errors.global_error').red unless e. raise e end |
#normalize_args(args) ⇒ Object
rubocop:enable Lint/RescueException
32 33 34 35 36 |
# File 'lib/vagrant-rimu/commands/abstract_command.rb', line 32 def normalize_args(args) return args if args.nil? args.pop if args.size > 0 && args.last == '--' args end |