Sha256: c231324e95886cbdbfd5d51392af752adc1ed2bfa9cb38dabbc8bba7439128cc

Contents?: true

Size: 872 Bytes

Versions: 15

Compression:

Stored size: 872 Bytes

Contents

module Oscar::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

15 entries across 15 versions & 1 rubygems

Version Path
oscar-0.6.0 lib/oscar/command/helpers.rb
oscar-0.5.6 lib/oscar/command/helpers.rb
oscar-0.5.5 lib/oscar/command/helpers.rb
oscar-0.5.4 lib/oscar/command/helpers.rb
oscar-0.5.3 lib/oscar/command/helpers.rb
oscar-0.5.2 lib/oscar/command/helpers.rb
oscar-0.5.1 lib/oscar/command/helpers.rb
oscar-0.5.0 lib/oscar/command/helpers.rb
oscar-0.4.3 lib/oscar/command/helpers.rb
oscar-0.4.2 lib/oscar/command/helpers.rb
oscar-0.4.1 lib/oscar/command/helpers.rb
oscar-0.4.0 lib/oscar/command/helpers.rb
oscar-0.3.2 lib/oscar/command/helpers.rb
oscar-0.3.1 lib/oscar/command/helpers.rb
oscar-0.3.0 lib/oscar/command/helpers.rb