Sha256: e90cc59d04143e9e82a2a0a0014d64a5c3a095db47f2140c5f672683ef947f08
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Relish module Command class Help < Base desc 'show this usage' command :default do puts "=== Available Commands\n\n" Dsl::HelpText.commands.each do |command, list| list.each {|hash| Formatter.new(command, hash).format } end end class Formatter attr_reader :command, :usage, :description def initialize(command, hash) @command = command @usage, @description = *hash.to_a.flatten end def usage @usage == 'default' ? @command : @usage end def format description.split("\n").each_with_index do |part, index| puts "#{format_usage(index)} # #{part}" end end def format_usage(index) if index.zero? usage.ljust(max_usage_length) else " " * max_usage_length end end def max_usage_length Dsl::HelpText.max_usage_length end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
relish-0.1.0 | lib/relish/commands/help.rb |