Class: CommandKit::Commands::Subcommand Private
- Inherits:
-
Object
- Object
- CommandKit::Commands::Subcommand
- Defined in:
- lib/command_kit/commands/subcommand.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a registered subcommand.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aliases ⇒ Array<String>
readonly
private
Optional alias names for the subcommand.
-
#command ⇒ Class
readonly
private
The command class.
-
#summary ⇒ String?
readonly
private
A short summary for the subcommand.
Class Method Summary collapse
-
.summary(command) ⇒ String?
private
Derives a summary from the command's description.
Instance Method Summary collapse
-
#initialize(command, summary: self.class.summary(command), aliases: []) ⇒ Subcommand
constructor
private
Initializes the subcommand.
Constructor Details
#initialize(command, summary: self.class.summary(command), aliases: []) ⇒ Subcommand
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.
Initializes the subcommand.
40 41 42 43 44 45 |
# File 'lib/command_kit/commands/subcommand.rb', line 40 def initialize(command, summary: self.class.summary(command), aliases: []) @command = command @summary = summary @aliases = aliases.map(&:to_s) end |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
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.
Optional alias names for the subcommand.
25 26 27 |
# File 'lib/command_kit/commands/subcommand.rb', line 25 def aliases @aliases end |
#command ⇒ Class (readonly)
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.
The command class.
15 16 17 |
# File 'lib/command_kit/commands/subcommand.rb', line 15 def command @command end |
#summary ⇒ String? (readonly)
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.
A short summary for the subcommand.
20 21 22 |
# File 'lib/command_kit/commands/subcommand.rb', line 20 def summary @summary end |
Class Method Details
.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.
57 58 59 60 61 62 63 64 |
# File 'lib/command_kit/commands/subcommand.rb', line 57 def self.summary(command) if command.respond_to?(:description) if (desc = command.description) # extract the first sentence desc[/^[^\.]+/] end end end |