Sha256: 766a6655c5444fc150d80bb6035f1770eb53f556433dfe9e8ab5af8e220aa828

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 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 Ecic
  class Command < Thor
    class << self
      def dispatch(m, args, options, config)
        # Allow calling for help via:
        #   ecic command help
        #   ecic command -h
        #   ecic command --help
        #   ecic command -D
        #
        # as well thor's normal way:
        #
        #   ecic help command
        help_flags = Thor::HELP_MAPPINGS + ["help"]
        if args.length > 1 && !(args & help_flags).empty?
          args -= help_flags
          args.insert(-2, "help")
        end

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

        super
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ecic-0.6.2 lib/ecic/command.rb
ecic-0.6.1 lib/ecic/command.rb
ecic-0.6.0 lib/ecic/command.rb
ecic-0.5.0 lib/ecic/command.rb
ecic-0.4.0 lib/ecic/command.rb
ecic-0.3.0 lib/ecic/command.rb
ecic-0.2.2 lib/ecic/command.rb
ecic-0.2.1 lib/ecic/command.rb
ecic-0.2.0 lib/ecic/command.rb
ecic-0.1.0 lib/ecic/command.rb