Sha256: b7c44d849d15ff37f957db0f45627e6dee34dc551b5ba84d9cb1dd250acb7042

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

class Gem::Commands::ManpagesCommand < Gem::Command
  include Gem::VersionOption

  def initialize
    super "manpages", "Handling manpages in gems",
      command: nil,
      version: Gem::Requirement.default,
      latest:  false,
      all:     false

    add_update_all_option
  end

  def usage
    "gem manpages"
  end

  def add_update_all_option
    add_option("-u", "--update-all",
      "Search for manpages in all installed gems and expose them to man") do |_, options|
      options[:update_all] = true
    end
  end

  def execute
    if options[:update_all]
      update_all
    else
      show_help
    end
  end

  def update_all
    specs = Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.gems
    specs.each do |*name_and_spec|
      spec = name_and_spec.pop
      next unless Manpages::ManFiles.new(spec.gem_dir).manpages_present? &&
          Manpages::GemVersion.new(spec).latest?

      say "Installing man pages for #{spec.name} #{spec.version}"
      target_dir = File.expand_path("#{Gem.bindir}/../share/man")
      Manpages::Install.new(spec, spec.gem_dir, target_dir).install_manpages
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/manpages-0.6.1/lib/rubygems/commands/manpages_command.rb
manpages-0.6.1 lib/rubygems/commands/manpages_command.rb
manpages-0.6.0 lib/rubygems/commands/manpages_command.rb
manpages-0.5.2 lib/rubygems/commands/manpages_command.rb
manpages-0.5.1 lib/rubygems/commands/manpages_command.rb