Sha256: 65a61da084f0b56ce4e1d2e02fde18635dcf790344cbfdebb7c16707601a4096

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

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

        #   aws_rsync --version
        #   aws_rsync -v
        version_flags = ["-v", "--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
aws-rsync-0.1.0 lib/aws_rsync/command.rb