Sha256: 5eb3fa0f02aa923ba0658eb219391fd9cd4654075045fa45cbf2b06fcdcaaeb5

Contents?: true

Size: 826 Bytes

Versions: 17

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

# Thor with subcommands that work correctly with help
class SubCommandBase < Thor
  # Set the subcommand banner.
  # rubocop:disable Style/OptionalBooleanParameter
  def self.banner(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
  # rubocop:enable Style/OptionalBooleanParameter

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
takeltau-0.44.15 lib/takeltau/lib/subcmd.rb
takeltau-0.44.14 lib/takeltau/lib/subcmd.rb
takeltau-0.44.12 lib/takeltau/lib/subcmd.rb
takeltau-0.44.11 lib/takeltau/lib/subcmd.rb
takeltau-0.44.8 lib/takeltau/lib/subcmd.rb
takeltau-0.44.2 lib/takeltau/lib/subcmd.rb
takeltau-0.43.23 lib/takeltau/lib/subcmd.rb
takeltau-0.43.21 lib/takeltau/lib/subcmd.rb
takeltau-0.43.19 lib/takeltau/lib/subcmd.rb
takeltau-0.43.16 lib/takeltau/lib/subcmd.rb
takeltau-0.43.15 lib/takeltau/lib/subcmd.rb
takeltau-0.43.14 lib/takeltau/lib/subcmd.rb
takeltau-0.43.10 lib/takeltau/lib/subcmd.rb
takeltau-0.43.6 lib/takeltau/lib/subcmd.rb
takeltau-0.43.4 lib/takeltau/lib/subcmd.rb
takeltau-0.43.2 lib/takeltau/lib/subcmd.rb
takeltau-0.43.1 lib/takeltau/lib/subcmd.rb