module HelpCompletionFormatPatch

Public Instance Methods

format() click to toggle source
# File lib/patches/gli.rb, line 13
def format
  name = @args.shift
  
  base = @command_finder.find_command(name)
  base = @command_finder.last_found_command if base.nil?
  base = @app if base.nil?
  
  prefix_to_match = @command_finder.last_unknown_command
  
  base.commands.reject {|_,c| c.nodoc}.values.map { |command|
    [command.name,command.aliases]
  }.flatten.compact.map(&:to_s).sort.select { |command_name|
    prefix_to_match.nil? || command_name =~ /^#{prefix_to_match}/
  }.join("\n")
end