Sha256: dd1f2cd5ce04c778c4fa0dc9d8f9f8182ef2f0dc3c79cf3fc714e4b336b844e6

Contents?: true

Size: 1.06 KB

Versions: 21

Compression:

Stored size: 1.06 KB

Contents

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

21 entries across 21 versions & 1 rubygems

Version Path
license_finder-3.0.4 lib/license_finder/cli/patched_thor.rb
license_finder-3.0.2 lib/license_finder/cli/patched_thor.rb
license_finder-3.0.1 lib/license_finder/cli/patched_thor.rb
license_finder-3.0.0 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.2 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.1 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc9 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc8 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc7 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc6 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc5 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc4 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc3 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc2 lib/license_finder/cli/patched_thor.rb
license_finder-2.1.0.rc1 lib/license_finder/cli/patched_thor.rb
license_finder-2.0.4 lib/license_finder/cli/patched_thor.rb
license_finder-2.0.3 lib/license_finder/cli/patched_thor.rb
license_finder-2.0.2 lib/license_finder/cli/patched_thor.rb
license_finder-2.0.1 lib/license_finder/cli/patched_thor.rb