diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rcl_cmd_args.erl | 13 | ||||
-rw-r--r-- | src/relcool.erl | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/rcl_cmd_args.erl b/src/rcl_cmd_args.erl index dc176be..3bb9f41 100644 --- a/src/rcl_cmd_args.erl +++ b/src/rcl_cmd_args.erl @@ -34,7 +34,8 @@ relcool:error(). args2state({error, Detail}) -> ?RCL_ERROR({opt_parse, Detail}); -args2state({ok, {Opts, Targets}}) -> +args2state({ok, {Opts, Target}}) + when erlang:length(Target) == 0; erlang:length(Target) == 1 -> RelName = proplists:get_value(relname, Opts, undefined), RelVsn = proplists:get_value(relvsn, Opts, undefined), case create_log(Opts, @@ -43,15 +44,19 @@ args2state({ok, {Opts, Targets}}) -> Error = {error, _} -> Error; {ok, CommandLineConfig} -> - case validate_configs(Targets) of + case validate_configs(Target) of Error = {error, _} -> Error; {ok, Configs} -> - {ok, {rcl_state:new(CommandLineConfig, Configs), Configs}} + {ok, rcl_state:new(CommandLineConfig, Configs)} end - end. + end; +args2state({ok, {_Opts, Targets}}) -> + ?RCL_ERROR({invalid_targets, Targets}). -spec format_error(Reason::term()) -> iolist(). +format_error({invalid_targets, Targets}) -> + io_lib:format("One config must be specified! not ~p~n", [Targets]); format_error({opt_parse, {invalid_option, Opt}}) -> io_lib:format("invalid option ~s~n", [Opt]); format_error({opt_parse, Arg}) -> diff --git a/src/relcool.erl b/src/relcool.erl index c6747ca..fb17711 100644 --- a/src/relcool.erl +++ b/src/relcool.erl @@ -43,7 +43,7 @@ main(Args) -> OptSpecList = opt_spec_list(), case rcl_cmd_args:args2state(getopt:parse(OptSpecList, Args)) of - {ok, {State, _Target}} -> + {ok, State} -> run_relcool_process(rcl_state:caller(State, command_line)); Error={error, _} -> report_error(rcl_state:caller(rcl_state:new([], []), |