Sha256: 693dcad029f2776af6234010c79d1f68ece5674aeac63f9b2c2b30530fe0fcf7

Contents?: true

Size: 1.1 KB

Versions: 46

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module LicenseFinder
  module CLI
    module Rootcommand
      # Helper to auto-generate the documentation for a group of commands
      def subcommand(namespace, klass, namespace_description)
        description = "#{namespace} [#{(klass.tasks.keys - ['help']).join('|')}]"
        desc description, "#{namespace_description} - see `license_finder #{namespace} help` for more information"
        super namespace, klass
      end
    end

    # Thor fix for `license_finder <subcommand> help <action>`
    module Subcommand
      # Hack to override the help message produced by Thor.
      # https://github.com/wycats/thor/issues/261#issuecomment-16880836
      def banner(command, _namespace = nil, _subcommand = nil)
        "#{basename} #{underscore_name(name)} #{command.usage}"
      end

      protected

      def underscore_name(name)
        underscored = name.split('::').last
        underscored.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        underscored.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
        underscored.tr!('-', '_')
        underscored.downcase
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
license_finder-7.1.0 lib/license_finder/cli/patched_thor.rb
license_finder-7.0.1 lib/license_finder/cli/patched_thor.rb
license_finder-7.0.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.15.0 lib/license_finder/cli/patched_thor.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/cli/patched_thor.rb
license_finder-6.14.2 lib/license_finder/cli/patched_thor.rb
license_finder-6.14.1 lib/license_finder/cli/patched_thor.rb
license_finder-6.13.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.12.2 lib/license_finder/cli/patched_thor.rb
license_finder-6.12.1 lib/license_finder/cli/patched_thor.rb
license_finder-6.12.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.11.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.10.1 lib/license_finder/cli/patched_thor.rb
license_finder-6.10.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.9.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.8.2 lib/license_finder/cli/patched_thor.rb
license_finder-6.8.1 lib/license_finder/cli/patched_thor.rb
license_finder-6.8.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.7.0 lib/license_finder/cli/patched_thor.rb
license_finder-6.6.2 lib/license_finder/cli/patched_thor.rb