Class: GemKit::Release::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gem_kit/release/cli.rb

Overview

The command line behind gem kit, on Thor.

Thor gives us the parts a hand-rolled parser always ends up needing badly: per-command help built from the desc/method_option declarations, a subcommand listing, and — the reason for choosing it over a plain option parser — Thor::Group and Thor::Actions, the same generator machinery Rails' rails generate is built on. gem kit setup is a generator, so it gets create/identical/conflict reporting and the overwrite prompt without writing any of it.

gem kit                    the listing
gem kit help bump          that command's options

Each command here is a thin front for a plain object under CLI::; the work itself is in Gate, VersionFile, Changelog and Deprecate.

Constant Summary collapse

WORKFLOW =

The order the commands go in — printed above the command listing so nobody has to guess when to commit or when to write the changelog. The question the process is easy to get wrong on is exactly the one this answers: the changelog is written after the bump, then the two are committed together, and only then does release run.

<<~TXT
  Release, in order:

    1. bin/test                        # green suite
    2. gem kit bump [SEGMENT]          # move the version, relock the Gemfile
    3. gem kit changelog --write       # AI CLI drafts this version's entry
    4. gem kit changelog [VERSION]     # lint the entry, confirm ready to release
    5. git commit -am "Release ..."    # bump + lockfile + entry, one commit
    6. gem kit release                 # gate, build, push, tag (also pushes the tag)
    7. git push                        # publish the release commit
TXT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

gem kit with no arguments lists the commands rather than erroring.



65
66
67
# File 'lib/gem_kit/release/cli.rb', line 65

def self.banner(command, _namespace = nil, _subcommand = false)
  "gem kit #{command.usage}"
end

.exit_on_failure?Boolean

Thor asks; without it every invocation warns.

Returns:

  • (Boolean)


62
# File 'lib/gem_kit/release/cli.rb', line 62

def self.exit_on_failure? = true

.help(shell, subcommand = false) ⇒ Object

Prepend the workflow to the top-level gem kit help. gem kit help <command> sets subcommand=true and lands here too; that page already has its own long_desc, so leave it alone.



72
73
74
75
76
# File 'lib/gem_kit/release/cli.rb', line 72

def self.help(shell, subcommand = false)
  shell.say(WORKFLOW) unless subcommand
  shell.say unless subcommand
  super
end

Instance Method Details

#bump(segment = "patch") ⇒ Object



98
99
100
# File 'lib/gem_kit/release/cli.rb', line 98

def bump(segment = "patch")
  Commands::Bump.new(options).call(segment)
end

#changelog(version = nil) ⇒ Object



117
118
119
# File 'lib/gem_kit/release/cli.rb', line 117

def changelog(version = nil)
  Commands::Changelog.new(options).call(version)
end

#deprecations(version = nil) ⇒ Object



130
131
132
# File 'lib/gem_kit/release/cli.rb', line 130

def deprecations(version = nil)
  Commands::Deprecations.new(options).call(version)
end

#releaseObject



156
157
158
# File 'lib/gem_kit/release/cli.rb', line 156

def release
  Commands::Release.new(options).call
end

#tagObject



172
173
174
# File 'lib/gem_kit/release/cli.rb', line 172

def tag
  Commands::Tag.new(options).call
end