Sha256: 53b81fb5b6d9a17fd8b9abcc05a4f87aceb3c741e7ebb20a4eb25c1e3da5fed4

Contents?: true

Size: 1.07 KB

Versions: 23

Compression:

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

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

        super
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ufo-3.5.5 lib/ufo/command.rb
ufo-3.5.4 lib/ufo/command.rb
ufo-3.5.3 lib/ufo/command.rb
ufo-3.5.2 lib/ufo/command.rb
ufo-3.5.1 lib/ufo/command.rb
ufo-3.5.0 lib/ufo/command.rb
ufo-3.4.4 lib/ufo/command.rb
ufo-3.4.3 lib/ufo/command.rb
ufo-3.4.2 lib/ufo/command.rb
ufo-3.4.1 lib/ufo/command.rb
ufo-3.4.0 lib/ufo/command.rb
ufo-3.3.2 lib/ufo/command.rb
ufo-3.3.1 lib/ufo/command.rb
ufo-3.3.0 lib/ufo/command.rb
ufo-3.2.2 lib/ufo/command.rb
ufo-3.2.1 lib/ufo/command.rb
ufo-3.2.0 lib/ufo/command.rb
ufo-3.1.2 lib/ufo/command.rb
ufo-3.1.1 lib/ufo/command.rb
ufo-3.1.0 lib/ufo/command.rb