Sha256: 99f81d36d8e3ec655ec8dc01e6e7037944db4d19ac4d14fe03df6c11b9fc0fb0

Contents?: true

Size: 846 Bytes

Versions: 57

Compression:

Stored size: 846 Bytes

Contents

module GLI
  module Commands
    module HelpModules
      class HelpCompletionFormat
        def initialize(app,command_finder,args)
          @app = app
          @command_finder = command_finder
          @command_finder.squelch_stderr = true
          @args = args
        end

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

      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
gli-2.22.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.22.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.5 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.4 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.3 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.2 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.21.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.20.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.20.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.19.2 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.19.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.19.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.18.2 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.18.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.18.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.17.2 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.17.1 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.17.0 lib/gli/commands/help_modules/help_completion_format.rb
gli-2.16.1 lib/gli/commands/help_modules/help_completion_format.rb