Sha256: 612df95e83317baee765eb93dffa935bf94ea07be41ee445ab2b4c75bc6eaa1e

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

module GLI
  # Indicates that the command line invocation was bad
  class BadCommandLine < Exception
    def exit_code; -1; end
  end

  # Indicates the bad command line was an unknown command
  class UnknownCommand < BadCommandLine
  end

  # Indicates the bad command line was an unknown global argument
  class UnknownGlobalArgument < BadCommandLine
  end

  # Indicates the bad command line was an unknown command argument
  class UnknownCommandArgument < BadCommandLine
    attr_reader :command
    # +message+:: the error message to show the user
    # +command+:: the command we were using to parse command-specific options
    def initialize(message,command)
      super(message)
      @command = command
    end
  end

  # Raise this if you want to use an exit status that isn't the default
  # provided by GLI.  Note that GLI#exit_now! might be a bit more to your liking.
  #
  # Example:
  #
  #     raise CustomExit.new("Not connected to DB",-5) unless connected?
  #     raise CustomExit.new("Bad SQL",-6) unless valid_sql?(args[0])
  #
  class CustomExit < Exception
    attr_reader :exit_code #:nodoc:
    # Create a custom exit exception
    #
    # +message+:: String containing error message to show the user
    # +exit_code+:: the exit code to use (as an Int), overridding GLI's default
    def initialize(message,exit_code)
      super(message)
      @exit_code = exit_code
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
gli-1.6.0 lib/gli/exceptions.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
gli-1.5.1 lib/gli/exceptions.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
iisconfig-0.0.1.pre2 build/bundler/ruby/1.9.1/gems/gli-1.4.0/lib/gli/exceptions.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
iisconfig-0.0.1.pre1 build/bundler/ruby/1.9.1/gems/gli-1.4.0/lib/gli/exceptions.rb
gli-1.4.0 lib/gli/exceptions.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
gli-1.3.7 lib/gli/exceptions.rb
gli-1.3.6 lib/gli/exceptions.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
gli-1.3.5 lib/gli/exceptions.rb
brightbox-cli-0.14.1 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb
brightbox-cli-0.14.0 lib/brightbox-cli/vendor/gli/lib/gli/exceptions.rb