mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Update getopt
This commit is contained in:
parent
ac5948d910
commit
a3615a4b82
1 changed files with 13 additions and 6 deletions
|
@ -13,6 +13,13 @@
|
|||
|
||||
-export([parse/2, usage/2, usage/3, usage/4]).
|
||||
|
||||
-export_type([arg_type/0,
|
||||
arg_value/0,
|
||||
arg_spec/0,
|
||||
simple_option/0,
|
||||
compound_option/0,
|
||||
option/0,
|
||||
option_spec/0]).
|
||||
|
||||
-define(TAB_LENGTH, 8).
|
||||
%% Indentation of the help messages in number of tabs.
|
||||
|
@ -114,7 +121,7 @@ parse_option_long(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
|
|||
case lists:keyfind(Long, ?OPT_LONG, OptSpecList) of
|
||||
{Name, _Short, Long, undefined, _Help} ->
|
||||
parse(OptSpecList, [Name | OptAcc], ArgAcc, ArgPos, Args);
|
||||
|
||||
|
||||
{_Name, _Short, Long, _ArgSpec, _Help} = OptSpec ->
|
||||
% The option argument string is empty, but the option requires
|
||||
% an argument, so we look into the next string in the list.
|
||||
|
@ -217,7 +224,7 @@ parse_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, [] = Args, {Name, _Sh
|
|||
_ ->
|
||||
throw({error, {missing_option_arg, Name}})
|
||||
end.
|
||||
|
||||
|
||||
|
||||
%% @doc Find the option for the discrete argument in position specified in the
|
||||
%% Pos argument.
|
||||
|
@ -318,7 +325,7 @@ is_arg_true(Arg) ->
|
|||
(Arg =:= "on") orelse (Arg =:= "enabled") orelse
|
||||
(Arg =:= "1").
|
||||
|
||||
|
||||
|
||||
-spec is_arg_false(string()) -> boolean().
|
||||
is_arg_false(Arg) ->
|
||||
(Arg =:= "false") orelse (Arg =:= "f") orelse
|
||||
|
@ -362,7 +369,7 @@ is_float_arg([_Head | _Tail]) ->
|
|||
false;
|
||||
is_float_arg([]) ->
|
||||
true.
|
||||
|
||||
|
||||
|
||||
%% @doc Show a message on stdout indicating the command line options and
|
||||
%% arguments that are supported by the program.
|
||||
|
@ -441,8 +448,8 @@ usage_options(OptSpecList) ->
|
|||
lists:flatten(lists:reverse(usage_options_reverse(OptSpecList, []))).
|
||||
|
||||
usage_options_reverse([{Name, Short, Long, _ArgSpec, Help} | Tail], Acc) ->
|
||||
Prefix =
|
||||
case Long of
|
||||
Prefix =
|
||||
case Long of
|
||||
undefined ->
|
||||
case Short of
|
||||
% Neither short nor long form (non-option argument).
|
||||
|
|
Loading…
Reference in a new issue