Sha256: c3962a8282eab6b60446a952e4e696cf51e2009de28d9a3fc0d3fb0441e03fe4

Contents?: true

Size: 897 Bytes

Versions: 39

Compression:

Stored size: 897 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
  # rubocop:disable Lint/EmptyBlock
  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 Lint/EmptyBlock
  # 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

39 entries across 39 versions & 1 rubygems

Version Path
takeltau-0.46.9 lib/takeltau/lib/subcmd.rb
takeltau-0.46.8 lib/takeltau/lib/subcmd.rb
takeltau-0.46.5 lib/takeltau/lib/subcmd.rb
takeltau-0.46.1 lib/takeltau/lib/subcmd.rb
takeltau-0.46.0 lib/takeltau/lib/subcmd.rb
takeltau-0.45.27 lib/takeltau/lib/subcmd.rb
takeltau-0.45.26 lib/takeltau/lib/subcmd.rb
takeltau-0.45.24 lib/takeltau/lib/subcmd.rb
takeltau-0.45.23 lib/takeltau/lib/subcmd.rb
takeltau-0.45.22 lib/takeltau/lib/subcmd.rb
takeltau-0.45.21 lib/takeltau/lib/subcmd.rb
takeltau-0.45.19 lib/takeltau/lib/subcmd.rb
takeltau-0.45.17 lib/takeltau/lib/subcmd.rb
takeltau-0.45.16 lib/takeltau/lib/subcmd.rb
takeltau-0.45.14 lib/takeltau/lib/subcmd.rb
takeltau-0.45.13 lib/takeltau/lib/subcmd.rb
takeltau-0.45.12 lib/takeltau/lib/subcmd.rb
takeltau-0.45.11 lib/takeltau/lib/subcmd.rb
takeltau-0.45.10 lib/takeltau/lib/subcmd.rb
takeltau-0.45.9 lib/takeltau/lib/subcmd.rb