anchor.diff:                     ArgSpec :: arg_spec(),
                      Help    :: string() | undefined
                     }.
  +%% Output streams
  +-type output_stream() :: 'standard_io' | 'standard_error'.
   
   
   %% @doc  Parse the command line options and arguments returning a list of tuples
  
positive.code:                 undefined ->
                      throw({error, {invalid_option_arg, OptStr}});
                  _ ->
                      parse(OptSpecList, [convert_option_arg(OptSpec, Arg) | OptAcc], ArgAcc, ArgPos, Args)
              end;
          false ->
              throw({error, {invalid_option, OptStr}})
  
negative.code:     OptAcc.
  
  
  %% @doc Add an option with no argument.
  -spec add_option_no_arg(option_spec(), [option()]) -> [option()].
  add_option_no_arg({Name, _Short, _Long, ArgSpec, _Help} = OptSpec, OptAcc) ->
      case arg_spec_type(ArgSpec) of
          boolean ->
              %% Special case for boolean arguments: if there is no argument we
              %% set the value to 'true'.
              add_arg(OptSpec, true, OptAcc);
          integer ->
              %% Special case for integer arguments: if the option had not been set
              %% before we set the value to 1; if not we increment the previous value
              %% the option had. This is needed to support options like "-vvv" to
              %% return something like {verbose, 3}.
              add_implicit_integer_arg(OptSpec, OptAcc);
          _ ->
              throw({error, {missing_option_arg, Name}})
      end.
  
  
  %% @doc Add an option with argument converting it to the data type indicated by the
  %%      argument specification.
  -spec add_option_arg(option_spec(), string(), [option()]) -> [option()].
  add_option_arg({Name, _Short, _Long, ArgSpec, _Help} = OptSpec, Arg, OptAcc) ->
      ArgSpecType = arg_spec_type(ArgSpec),
      case (ArgSpecType =:= boolean) andalso not is_boolean_arg(Arg) of
          true ->
              %% Special case for booleans: when the next string is not a boolean
              %% argument we assume the value is 'true'.
              add_arg(OptSpec, true, OptAcc);
          false ->
              case (ArgSpecType =:= integer) andalso not is_integer_arg(Arg) of
                  true ->
                      %% Special case for integer arguments: if the option had not been set
                      %% before we set the value to 1; if not we increment the previous value
                      %% the option had. This is needed to support options like "-vvv" to
                      %% return something like {verbose, 3}.
                      add_implicit_integer_arg(OptSpec, OptAcc);
                  false ->
                      try
                         add_arg(OptSpec, to_type(ArgSpecType, Arg), OptAcc)
                      catch
                          error:_ ->
                              throw({error, {invalid_option_arg, {Name, Arg}}})
                      end
              end
      end.
  
  
  %% Add an option with an integer argument.
  -spec add_implicit_integer_arg(option_spec(), [option()]) -> [option()].
  add_implicit_integer_arg({Name, _Short, _Long, _ArgSpec, _Help}, OptAcc) ->
      case lists:keyfind(Name, 1, OptAcc) of
          {Name, Count} ->
              lists:keyreplace(Name, 1, OptAcc, {Name, Count + 1});
          false ->
              [{Name, 1} | OptAcc]
      end.
  
  
  %% @doc Add an option with an argument and convert it to the data type corresponding
  %%      to the argument specification.
  -spec add_arg(option_spec(), arg_value(), [option()]) -> [option()].
  add_arg({Name, _Short, _Long, _ArgSpec, _Help}, Arg, OptAcc) ->
      [{Name, Arg} | lists:keydelete(Name, 1, OptAcc)].
  
  
  %% @doc Retrieve the data type form an argument specification.
  