Skip to content

Commit 5c10755

Browse files
authored
Merge pull request basho#90 from redclawtech/fix_empty_kv
Don't throw error on empy argument
2 parents dc28212 + 06247fd commit 5c10755

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/clique_error.erl

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ format(_Cmd, {error, {invalid_flags, Flags}}) ->
5858
status(io_lib:format("Invalid Flags: ~p", [Flags]));
5959
format(_Cmd, {error, {invalid_flag_value, {Name, Val}}}) ->
6060
status(io_lib:format("Invalid value: ~p for flag: ~p", [Val, Name]));
61+
format(_Cmd, {error, {invalid_kv_arg, Arg}}) ->
62+
status(io_lib:format("Empty value in argument: ~p", [Arg]));
6163
format(_Cmd, {error, {invalid_flag_combination, Msg}}) ->
6264
status(io_lib:format("Error: ~ts", [Msg]));
6365
format(_Cmd, {error, {invalid_value, Val}}) ->

src/clique_parser.erl

+7-2
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,13 @@ parse_valid_arg_value_with_equal_sign_test() ->
380380
%% All arguments must be of type k=v
381381
parse_invalid_kv_arg_test() ->
382382
Spec = spec(),
383-
Args = ["ayo"],
384-
?assertMatch({error, _}, parse({Spec, Args})).
383+
%% Argument with equal sign and no value
384+
ArgsNoVal = ["ayo="],
385+
?assertMatch({error, {invalid_kv_arg, _}}, parse({Spec, ArgsNoVal})),
386+
%% Argument without equal sign and no value
387+
ArgsNoEqualAndNoVal = ["ayo"],
388+
?assertMatch({error, {invalid_kv_arg, _}}, parse({Spec, ArgsNoEqualAndNoVal})).
389+
385390

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

0 commit comments

Comments
 (0)