Class: SubCommandBase
- Inherits:
-
Thor
- Object
- Thor
- SubCommandBase
- Defined in:
- lib/takeltau/lib/subcmd.rb
Overview
Thor with subcommands that work correctly with help
Direct Known Subclasses
Takeltau::Completion, Takeltau::Docker, Takeltau::DockerCheck, Takeltau::DockerContainer, Takeltau::DockerContainerCheck, Takeltau::DockerImage, Takeltau::DockerImageTag, Takeltau::Git, Takeltau::GitCheck, Takeltau::Hg, Takeltau::Info, Takeltau::InfoProject, Takeltau::InfoStatus, Takeltau::Init, Takeltau::InitPacker, Takeltau::InitTakelage, Takeltau::Mutagen, Takeltau::MutagenCheck, Takeltau::MutagenSocket, Takeltau::Self, Takeltau::SelfConfig, Takeltau::Ship, Takeltau::ShipCompletion, Takeltau::ShipContainer, Takeltau::ShipContainerCheck, Takeltau::ShipInfo, Takeltau::ShipPorts, Takeltau::ShipProject
Class Method Summary collapse
-
.banner(command, _namespace = nil, _subcommand = false) ⇒ Object
Set the subcommand banner.
-
.subcommand_prefix ⇒ Object
Set the subcommand prefix.
Class Method Details
.banner(command, _namespace = nil, _subcommand = false) ⇒ Object
Set the subcommand banner. rubocop:disable Style/OptionalBooleanParameter rubocop:disable Lint/EmptyBlock
8 9 10 11 12 13 14 15 |
# File 'lib/takeltau/lib/subcmd.rb', line 8 def self.(command, _namespace = nil, _subcommand = false) subcommand = subcommand_prefix name = $PROGRAM_NAME name = ENV['TAKELAGE_TAU_TAU'] unless ENV['TAKELAGE_TAU_TAU'].nil? subcommand.gsub!(/ship\s*/) {} unless ENV['TAKELAGE_TAU_SHIP'].nil? name = File.basename(name) [name, subcommand, command.usage].reject(&:empty?).join(' ') end |
.subcommand_prefix ⇒ Object
Set the subcommand prefix.
20 21 22 23 24 |
# File 'lib/takeltau/lib/subcmd.rb', line 20 def self.subcommand_prefix name.gsub(/.*::/, '') .gsub(/^[A-Z]/) { |match| match[0].downcase } .gsub(/[A-Z]/) { |match| " #{match[0].downcase}" } end |