class Convoy::Formatter::DefaultHelpFormatter
Attributes
context[R]
setup[R]
Public Class Methods
new(setup, context)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 6 def initialize(setup, context) @setup = setup @context = context end
Public Instance Methods
print(parser)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 11 def print(parser) options = Options.new(parser, setup, context) commands = Commands.new(setup, context) current_command = Commands.command_for(setup, context) # Uncomment the following line if you want the screen # to be cleared before the --help messages show. # # system('clear') puts StreamOutputFormatter.new($stdout, :max_output_width => Terminal.width) do |f| if setup.summary_for != '' && !setup.summary_for.nil? f.puts setup.summary_for, :newlines => 2 end # if (setup.description_for != '' && !setup.description_for.nil?) && current_command.summary == setup.summary_for # f.indent(4) do |f_inner| # f_inner.puts setup.description_for, :newlines => 2 # end # end name_help(current_command, f) version_help(current_command, f) usage_help(current_command, f) commands_help(commands, f) options_help(options, f) end end
Private Instance Methods
commands_help(commands, f)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 100 def commands_help(commands, f) if commands.count > 0 f.puts " \x1B[38;5;255mCOMMANDS\x1B[0m" f.indent(4) do |f| f.grid(:columns => 3) do |t| commands.each do |command| t.row command.name_with_aliases.ljust(10, ' '), " \xe2\x86\x92 ", command.outline end end f.newline end end end
name_help(current_command, f)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 39 def name_help(current_command, f) if setup.description_for(context) != '' f.indent(4) do |f| f.puts("\x1B[38;5;250m#{setup.description_for(context)}\x1B[0m", :newlines => 2) end end end
option_conflicts_help(option, t)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 80 def option_conflicts_help(option, t) if option.has_conflicts? t.row '', '', "- #{option.conflicts}" end end
option_dependencies_help(option, t)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 86 def option_dependencies_help(option, t) if option.has_dependencies? t.row '', '', "- #{option.dependencies}" end end
option_validations_help(option, t)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 92 def option_validations_help(option, t) if option.has_validations? option.validations.each do |validation| t.row '', '', "- #{validation}" end end end
options_help(options, f)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 61 def options_help(options, f) if options.count > 0 f.puts " \x1B[38;5;255mFLAGS\x1B[0m" f.indent(4) do |f| f.grid(:columns => 3) do |t| options.each do |option| unless option.usage == '--verbosity, <s>' || option.usage == '--error-output-format, <s>' || option.usage == '-v, --version' t.row option.usage.ljust(10, ' '), " \xe2\x86\x92 ", option.description option_conflicts_help(option, t) option_dependencies_help(option, t) option_validations_help(option, t) end end end f.newline end end end
usage_help(current_command, f)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 55 def usage_help(current_command, f) f.indent(4) do |f| f.puts "\x1B[38;5;250m Usage: \x1B[38;5;46m#{current_command.usage}\x1B[0m", :newlines => 2 end end
version_help(current_command, f)
click to toggle source
# File lib/convoy/formatter/default_help_formatter.rb, line 47 def version_help(current_command, f) if setup.version f.indent(4) do |f| f.puts "\x1B[38;5;250mVersion: \x1B[38;5;46m#{setup.version}\x1B[0m", :newlines => 1 end end end