Sha256: 7fb0042d0ce6cb98ee8b814718e43a4e9fc287ae34154b902d704bdb0fb361b5

Contents?: true

Size: 817 Bytes

Versions: 14

Compression:

Stored size: 817 Bytes

Contents

class Ppl::Command::Help < Ppl::Application::Command

  attr_accessor :command_suite

  def initialize
    @name        = "help"
    @description = "Show a list of commands"
  end

  def execute(input, output)
    @command_suite.sort_by_name
    max_name_length = 0

    @command_suite.each do |command|
      name_length = command.name.length
      if name_length > max_name_length
        max_name_length = name_length
      end
    end

    output.line("usage: ppl <command>")
    output.line(nil)

    @command_suite.each do |command|
      name        = command.name
      description = command.description

      if @name == name
        next
      end

      line = sprintf("   %-#{max_name_length}s   %s", name, description)

      output.line(line)
    end

    output.line(nil)
    return true
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ppl-1.5.2 lib/ppl/command/help.rb
ppl-1.5.1 lib/ppl/command/help.rb
ppl-1.5.0 lib/ppl/command/help.rb
ppl-1.4.1 lib/ppl/command/help.rb
ppl-1.3.0 lib/ppl/command/help.rb
ppl-1.2.0 lib/ppl/command/help.rb
ppl-1.1.0 lib/ppl/command/help.rb
ppl-1.0.6 lib/ppl/command/help.rb
ppl-1.0.5 lib/ppl/command/help.rb
ppl-1.0.4 lib/ppl/command/help.rb
ppl-1.0.3 lib/ppl/command/help.rb
ppl-1.0.1 lib/ppl/command/help.rb
ppl-1.0.0 lib/ppl/command/help.rb
ppl-0.9.0 lib/ppl/command/help.rb