Sha256: 38ddd6dbdc82ea6440348b9856e65ec665ba10268906149e9ebd525219223b3e

Contents?: true

Size: 879 Bytes

Versions: 24

Compression:

Stored size: 879 Bytes

Contents

module VagrantHosts::Command::Helpers

  private

  def split_argv
    @main_args, @subcommand, @sub_args = split_main_and_subcommand(@argv)
  end

  def invoke_subcommand
    if @subcommand and (klass = @subcommands.get(@subcommand))
      klass.new(@argv, @env).execute
    elsif @subcommand
      @env.ui.error "Unrecognized subcommand: #{@subcommand}"
      print_subcommand_help(:error)
    else
      print_subcommand_help
    end
  end

  def print_subcommand_help(output = :info)
    msg = []
    msg << "Usage: vagrant #{@cmd_name} <command> [<args>]"
    msg << ''
    msg << 'Available subcommands:'

    keys = []
    @subcommands.each { |(key, _)| keys << key }
    msg += keys.sort.map { |key| "     #{key}" }

    msg << ''
    msg << "For help on any individual command run `vagrant #{@cmd_name} <command> -h`"

    @env.ui.send(output, msg.join("\n"))
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
vagrant-hosts-2.9.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.8.3 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.8.2 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.8.1 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.8.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.7.1 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.7.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.6.2 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.6.1 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.6.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.5.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.4.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.3.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.2.4 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.2.3 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.2.2 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.2.1 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.2.0 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.1.5 lib/vagrant-hosts/command/helpers.rb
vagrant-hosts-2.1.4 lib/vagrant-hosts/command/helpers.rb