Class: SubCommandBase

Inherits:
Thor
  • Object
show all
Defined in:
lib/takelage/lib/subcmd.rb

Overview

Thor with subcommands that work correctly with help

Class Method Summary collapse

Class Method Details

Set the subcommand banner. rubocop:disable Style/OptionalBooleanParameter



7
8
9
# File 'lib/takelage/lib/subcmd.rb', line 7

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

.subcommand_prefixObject

Set the subcommand prefix.



13
14
15
16
17
# File 'lib/takelage/lib/subcmd.rb', line 13

def self.subcommand_prefix
  name.gsub(/.*::/, '')
      .gsub(/^[A-Z]/) { |match| match[0].downcase }
      .gsub(/[A-Z]/) { |match| " #{match[0].downcase}" }
end