Sha256: 64757b98809d5cb0b76d07c9b3edf768884819f1a63531531dca83c85697070d
Contents?: true
Size: 1.14 KB
Versions: 31
Compression:
Stored size: 1.14 KB
Contents
require 'vagrant' class PEBuild::Command::Base < Vagrant.plugin(2, :command) def initialize(argv, env) super split_argv @subcommands = { 'list' => PEBuild::Command::List, 'download' => PEBuild::Command::Download, 'copy' => PEBuild::Command::Copy, } end def execute if @subcommand execute_subcommand else print_help end end private def split_argv @main_args, @subcommand, @sub_args = split_main_and_subcommand(@argv) end def execute_subcommand if (klass = @subcommands[@subcommand]) klass.new(@argv, @env).execute else raise "Unrecognized subcommand #{@subcommand}" 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:" @subcommands.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
Version data entries
31 entries across 31 versions & 1 rubygems