Sha256: 665ffff8a0516efc892ba109036b072517a762c15c6d1bb92dfb8b8ae4fb8ba6

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "thor"

# Override thor's long_desc identation behavior
# https://github.com/erikhuda/thor/issues/398
class Thor
  module Shell
    class Basic
      def print_wrapped(message, options = {})
        message = "\n#{message}" unless message[0] == "\n"
        stdout.puts message
      end
    end
  end
end

module ThorTemplate
  class Command < Thor
    class << self
      def dispatch(m, args, options, config)
        # Allow calling for help via:
        #   thor_template command help
        #   thor_template command -h
        #   thor_template command --help
        #   thor_template command -D
        #
        # as well thor's normal way:
        #
        #   thor_template help command
        help_flags = Thor::HELP_MAPPINGS + ["help"]
        if args.length > 1 && !(args & help_flags).empty?
          args -= help_flags
          args.insert(-2, "help")
        end

        #   thor_template version
        #   thor_template --version
        version_flags = ["--version"]
        if args.length == 1 && !(args & version_flags).empty?
          args = ["version"]
        end

        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thor_template-2.2.0 lib/starter_project/lib/thor_template/command.rb