Sha256: f5bebe72c1d186c2ebf5db536c99229bbefd8763166a22ed278279e1fbb15053
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module CommandKit module Commands # # Represents a registered subcommand. # class Subcommand # The command class. # # @return [Class] attr_reader :command # A short summary for the subcommand. # # @return [String, nil] attr_reader :summary # Optional alias names for the subcommand. # # @return [Array<String>] attr_reader :aliases # # Initializes the subcommand. # # @param [Class] command # The command class. # # @param [String, nil] summary # A short summary for the subcommand. Defaults to the first sentence # of the command. # # @param [Array<String>] aliases # Optional alias names for the subcommand. # def initialize(command, summary: self.class.summary(command), aliases: []) @command = command @summary = summary @aliases = aliases.map(&:to_s) end def self.summary(command) if command.respond_to?(:description) if (desc = command.description) # extract the first sentence desc[/^[^\.]+/] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
command_kit-0.1.0.rc1 | lib/command_kit/commands/subcommand.rb |
command_kit-0.1.0.pre2 | lib/command_kit/commands/subcommand.rb |