Sha256: 57cc8642abc78aa2ec38bb3bd2819c4d7e2bce5ed12c8dd680487c93a7cc0b82
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'vagrant' module PEBuild class Command < Vagrant.plugin(2, :command) def initialize(argv, env) super @main_args, @subcommand, @sub_args = split_main_and_subcommand(argv) @subcommands = Vagrant::Registry.new register_subcommands end def execute if @subcommand and (klass = @subcommands.get(@subcommand)) klass.new(@argv, @env).execute elsif @subcommand raise "Unrecognized subcommand #{@subcommand}" else print_help end end private def register_subcommands @subcommands.register('copy') do require_relative 'command/copy' PEBuild::Command::Copy end @subcommands.register('download') do require_relative 'command/download' PEBuild::Command::Download end @subcommands.register('list') do require_relative 'command/list' PEBuild::Command::List end end def print_help cmd = 'vagrant pe-build' opts = OptionParser.new do |opts| opts.banner = "Usage: #{cmd} <command> [<args>]" opts.separator "" opts.separator "Available subcommands:" # Add the available subcommands as separators in order to print them # out as well. keys = [] @subcommands.each { |key, value| keys << key.to_s } keys.sort.each do |key| opts.separator " #{key}" end opts.separator "" opts.separator "For help on any individual command run `#{cmd} COMMAND -h`" end @env.ui.info(opts.help, :prefix => false) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-pe_build-0.2.0 | lib/pe_build/command.rb |
vagrant-pe_build-0.1.0 | lib/pe_build/command.rb |