Skip to content

Commit

Permalink
Merge pull request basho#90 from redclawtech/fix_empty_kv
Browse files Browse the repository at this point in the history
Don't throw error on empy argument
  • Loading branch information
martinsumner authored Feb 9, 2020
2 parents dc28212 + 06247fd commit 5c10755
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/clique_error.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ format(_Cmd, {error, {invalid_flags, Flags}}) ->
status(io_lib:format("Invalid Flags: ~p", [Flags]));
format(_Cmd, {error, {invalid_flag_value, {Name, Val}}}) ->
status(io_lib:format("Invalid value: ~p for flag: ~p", [Val, Name]));
format(_Cmd, {error, {invalid_kv_arg, Arg}}) ->
status(io_lib:format("Empty value in argument: ~p", [Arg]));
format(_Cmd, {error, {invalid_flag_combination, Msg}}) ->
status(io_lib:format("Error: ~ts", [Msg]));
format(_Cmd, {error, {invalid_value, Val}}) ->
Expand Down
9 changes: 7 additions & 2 deletions src/clique_parser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,13 @@ parse_valid_arg_value_with_equal_sign_test() ->
%% All arguments must be of type k=v
parse_invalid_kv_arg_test() ->
Spec = spec(),
Args = ["ayo"],
?assertMatch({error, _}, parse({Spec, Args})).
%% Argument with equal sign and no value
ArgsNoVal = ["ayo="],
?assertMatch({error, {invalid_kv_arg, _}}, parse({Spec, ArgsNoVal})),
%% Argument without equal sign and no value
ArgsNoEqualAndNoVal = ["ayo"],
?assertMatch({error, {invalid_kv_arg, _}}, parse({Spec, ArgsNoEqualAndNoVal})).


%% This succeeds, because we aren't validating the flag, just parsing
%% Note: Short flags get parsed into tuples with their character as first elem
Expand Down

0 comments on commit 5c10755

Please sign in to comment.