Method: CommandKit::Commands::Subcommand.summary

Defined in:
lib/command_kit/commands/subcommand.rb

.summary(command) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Derives a summary from the command's description.

Parameters:

  • command (Class)

    The command class.

Returns:

  • (String, nil)

    If the command responds to a #description method, the first sentence of the description will be returned. Otherwise nil is returned.



55
56
57
58
59
60
61
62
# File 'lib/command_kit/commands/subcommand.rb', line 55

def self.summary(command)
  if command.respond_to?(:description)
    if (desc = command.description)
      # extract the first sentence
      desc[/^[^\.]+/]
    end
  end
end