Sha256: 7bf48c6e06ddb2dec9fe5e902f0d9821e5b937d5872d7282036670b3f618b64d

Contents?: true

Size: 1.2 KB

Versions: 39

Compression:

Stored size: 1.2 KB

Contents

require 'vagrant'

class PEBuild::Command::Base < Vagrant.plugin(2, :command)

  def self.synopsis
    'Commands related to PE Installation'
  end

  def initialize(argv, env)
    super
    split_argv

    @subcommands = {
      'list'     => PEBuild::Command::List,
      'copy'     => PEBuild::Command::Copy,
      'facts'    => PEBuild::Command::Facts,
    }
  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

39 entries across 39 versions & 1 rubygems

Version Path
vagrant-pe_build-0.19.2 lib/pe_build/command/base.rb
vagrant-pe_build-0.19.1 lib/pe_build/command/base.rb
vagrant-pe_build-0.19.0 lib/pe_build/command/base.rb
vagrant-pe_build-0.18.2 lib/pe_build/command/base.rb
vagrant-pe_build-0.18.1 lib/pe_build/command/base.rb
vagrant-pe_build-0.18.0 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.14 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.13 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.12 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.11 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.10 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.9 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.8 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.7 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.6 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.5 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.4 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.3 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.2 lib/pe_build/command/base.rb
vagrant-pe_build-0.17.1 lib/pe_build/command/base.rb