Sha256: d9e78184c6258b1948dd3ac241ba441bcdf193d0a6fc87b0a8dd610673b39af4
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
module Relish module Command class Help < Base desc 'show this usage' command :default do puts <<-TEXT A <project> can be scoped by a publisher name. For example, if a publisher (rspec) has a project (rspec-core), then the <project> would be `rspec/rspec-core`. If you leave off the publisher name, then it defaults to the user (you), assuming you are publishing projects. TEXT 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
relish-0.7.1 | lib/relish/commands/help.rb |
relish-0.7 | lib/relish/commands/help.rb |
relish-0.6 | lib/relish/commands/help.rb |