Sha256: 772f6718342faa0237fa9df0e8b740db679ba586df23fc6c0e589e93d1f48bb6

Contents?: true

Size: 788 Bytes

Versions: 38

Compression:

Stored size: 788 Bytes

Contents

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

  name        "help"
  description "Show a list of commands"

  attr_accessor :command_suite

  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 self.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

38 entries across 38 versions & 1 rubygems

Version Path
ppl-3.0.1 lib/ppl/command/help.rb
ppl-3.0.0 lib/ppl/command/help.rb
ppl-2.4.1 lib/ppl/command/help.rb
ppl-2.4.0 lib/ppl/command/help.rb
ppl-2.3.3 lib/ppl/command/help.rb
ppl-2.3.2 lib/ppl/command/help.rb
ppl-2.3.1 lib/ppl/command/help.rb
ppl-2.3.0 lib/ppl/command/help.rb
ppl-2.2.0 lib/ppl/command/help.rb
ppl-2.1.0 lib/ppl/command/help.rb
ppl-2.0.0 lib/ppl/command/help.rb
ppl-1.25.0 lib/ppl/command/help.rb
ppl-1.24.0 lib/ppl/command/help.rb
ppl-1.23.0 lib/ppl/command/help.rb
ppl-1.22.2 lib/ppl/command/help.rb
ppl-1.22.1 lib/ppl/command/help.rb
ppl-1.22.0 lib/ppl/command/help.rb
ppl-1.21.0 lib/ppl/command/help.rb
ppl-1.20.0 lib/ppl/command/help.rb
ppl-1.19.0 lib/ppl/command/help.rb