Method: Git::Lib#assert_args_are_not_options

Defined in:
lib/git/lib.rb

#assert_args_are_not_options(arg_name, *args)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Validate that the given arguments cannot be mistaken for a command-line option

Parameters:

  • arg_name (String)

    the name of the arguments to mention in the error message

  • args (Array<String, nil>)

    the arguments to validate

Raises:

  • (ArgumentError)

    if any of the parameters are a string starting with a hyphen



838
839
840
841
842
843
# File 'lib/git/lib.rb', line 838

def assert_args_are_not_options(arg_name, *args)
  invalid_args = args.select { |arg| arg&.start_with?('-') }
  return unless invalid_args.any?

  raise ArgumentError, "Invalid #{arg_name}: '#{invalid_args.join("', '")}'"
end