Class: Gem::Commands::KitCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/kit_command.rb

Overview

gem kit <subcommand> — the only command this gem registers.

One registration rather than six keeps the toolchain under a name that is obviously ours, leaves gem help commands readable, and means nothing here can collide with a command RubyGems adds later.

This class is a bridge and nothing else: it hands the argv to the dry-cli registry, which owns the parsing and the help pages, and turns the result into a RubyGems exit. handle_options is deliberately inert — parsing here would swallow flags meant for a subcommand.

Instance Method Summary collapse

Constructor Details

#initializeKitCommand

Returns a new instance of KitCommand.



18
19
20
# File 'lib/rubygems/commands/kit_command.rb', line 18

def initialize
  super("kit", "Versioning, changelog and deprecation gates for this gem")
end

Instance Method Details

#argumentsObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/rubygems/commands/kit_command.rb', line 22

def arguments
  <<~TXT
    setup         copy DEPRECATIONS.md and RELEASE.md into this project
    bump          move the version, refusing to bump onto a deprecation deadline
    changelog     lint CHANGELOG.md, or have an AI CLI write this version's entry
    deprecations  list the deprecations this gem has not yet honoured
    release       gate, build and push this gem
    tag           tag the current version in git
  TXT
end

#defaults_strObject



35
# File 'lib/rubygems/commands/kit_command.rb', line 35

def defaults_str = "(lists the subcommands)"

#descriptionObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubygems/commands/kit_command.rb', line 37

def description
  <<~TXT
    A deprecation is a dated promise: it names its replacement and the version
    the old name stops existing in. These commands keep those promises — `bump`
    refuses to move onto a deadline, and `release` refuses to ship a version with
    an unkept promise or no changelog entry of its own.

    Everything is read from the .gemspec in the working directory, so there is
    nothing to configure in the common case.

    Run `gem kit SUBCOMMAND --help` for one subcommand's arguments, options and
    examples.
  TXT
end

#executeObject



58
59
60
61
62
63
64
# File 'lib/rubygems/commands/kit_command.rb', line 58

def execute
  # require_relative, not require: this resolves whether or not the gem
  # is installed, which keeps the command testable from the repo.
  require_relative "../../gem_kit/release/cli"

  terminate_interaction(GemKit::Release.run(@argv || []))
end

#handle_options(args) ⇒ Object

Inert on purpose: the dry-cli registry parses the argv, including the subcommand's own flags.



54
55
56
# File 'lib/rubygems/commands/kit_command.rb', line 54

def handle_options(args)
  @argv = args.dup
end

#usageObject



33
# File 'lib/rubygems/commands/kit_command.rb', line 33

def usage = "#{program_name} SUBCOMMAND [options]"