Class: VagrantPlugins::ProviderZone::Command::ZFSSnapshot
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderZone::Command::ZFSSnapshot
- Defined in:
- lib/vagrant-zones/command/zfssnapshot.rb
Overview
This is used to manage ZFS snapshtos for the zone
Instance Method Summary collapse
- #execute ⇒ Object
- #help ⇒ Object
-
#initialize(argv, env) ⇒ ZFSSnapshot
constructor
A new instance of ZFSSnapshot.
Constructor Details
#initialize(argv, env) ⇒ ZFSSnapshot
Returns a new instance of ZFSSnapshot.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-zones/command/zfssnapshot.rb', line 8 def initialize(argv, env) @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv) @subcommands = Vagrant::Registry.new @subcommands.register(:list) do require File.('list_snapshots', __dir__) ListSnapshots end @subcommands.register(:create) do require File.('create_snapshots', __dir__) CreateSnapshots end @subcommands.register(:delete) do require File.('delete_snapshots', __dir__) DeleteSnapshots end @subcommands.register(:configure) do require File.('configure_snapshots', __dir__) ConfigureSnapshots end super end |
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-zones/command/zfssnapshot.rb', line 31 def execute if @main_args.include?('-h') || @main_args.include?('--help') # Print the help for all the vagrant-zones commands. return help end command_class = @subcommands.get(:create) if @sub_command.nil? command_class = @subcommands.get(@sub_command.to_sym) if @sub_command = @sub_args unless @sub_args.nil? @logger.debug("Invoking command class: #{command_class} #{.inspect}") # Initialize and execute the command class command_class.new(, @env).execute end |
#help ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vagrant-zones/command/zfssnapshot.rb', line 47 def help opts = OptionParser.new do |subopts| subopts. = 'Usage: vagrant zone zfssnapshot <subcommand> [<args>]' subopts.separator '' subopts.separator 'Available subcommands:' # Add the available subcommands as separators in order to print them # out as well. keys = @subcommands.map { |(key, _value)| key.to_s }.sort keys.each do |key| subopts.separator " #{key}" end subopts.separator '' subopts.separator 'For help on any individual subcommand run `vagrant zone zfssnapshot <subcommand> -h`' end @env.ui.info(opts.help, :prefix => false) end |