Sha256: 4328f012a3b84f0f8460de0134f364a074dc315c26f65c1c2c43925186a853ef

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

module Xip
  module CliBase
    def define_commands(&blk)
      class_eval(&blk) if block_given?
    end

    def banner(command, nspace = true, subcommand = false)
      super(command, nspace, namespace != 'xip:cli')
    end

    def handle_argument_error(command, error, args, arity)
      name = [(namespace == 'xip:cli' ? nil : namespace), command.name].compact.join(" ")

      msg = "ERROR: \"#{basename} #{name}\" was called with "
      msg << "no arguments"               if     args.empty?
      msg << "arguments " << args.inspect unless args.empty?
      msg << "\nUsage: #{banner(command).inspect}"

      raise Thor::InvocationError, msg
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xip-2.0.0.beta2 lib/xip/cli_base.rb