mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 14:52:43 +00:00
options: fix exit code when using help options
Basically a cosmetic change. Fixes github issue #88.
This commit is contained in:
parent
a32cc6fcb2
commit
d4987bf5eb
@ -4711,16 +4711,20 @@ static int mpv_main(int argc, char *argv[])
|
||||
print_libav_versions();
|
||||
|
||||
if (!parse_cfgfiles(mpctx, mpctx->mconfig))
|
||||
exit_player(mpctx, EXIT_NONE, 1);
|
||||
|
||||
if (!m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
|
||||
argc, argv))
|
||||
{
|
||||
exit_player(mpctx, EXIT_ERROR, 1);
|
||||
|
||||
int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
|
||||
argc, argv);
|
||||
if (r < 0) {
|
||||
if (r <= M_OPT_EXIT) {
|
||||
exit_player(mpctx, EXIT_NONE, 0);
|
||||
} else {
|
||||
exit_player(mpctx, EXIT_ERROR, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (handle_help_options(mpctx))
|
||||
exit_player(mpctx, EXIT_NONE, 1);
|
||||
exit_player(mpctx, EXIT_NONE, 0);
|
||||
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V, "Configuration: " CONFIGURATION "\n");
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_V, "Command line:");
|
||||
|
@ -118,9 +118,11 @@ static bool parse_flag(bstr name, bstr f)
|
||||
return !!val;
|
||||
}
|
||||
|
||||
bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
|
||||
int argc, char **argv)
|
||||
// returns M_OPT_... error code
|
||||
int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret = M_OPT_UNKNOWN;
|
||||
int mode = 0;
|
||||
struct playlist_entry *local_start = NULL;
|
||||
bool shuffle = false;
|
||||
@ -139,8 +141,10 @@ bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
|
||||
int r;
|
||||
r = m_config_set_option_ext(config, p.arg, p.param,
|
||||
mode == LOCAL ? M_SETOPT_CHECK_ONLY : 0);
|
||||
if (r <= M_OPT_EXIT)
|
||||
if (r <= M_OPT_EXIT) {
|
||||
ret = r;
|
||||
goto err_out;
|
||||
}
|
||||
if (r < 0) {
|
||||
mp_tmsg(MSGT_CFGPARSER, MSGL_FATAL,
|
||||
"Setting commandline option --%.*s=%.*s failed.\n",
|
||||
@ -276,15 +280,13 @@ bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
|
||||
if (shuffle)
|
||||
playlist_shuffle(files);
|
||||
|
||||
talloc_free(local_params);
|
||||
assert(!config->file_local_mode);
|
||||
return true;
|
||||
ret = 0; // success
|
||||
|
||||
err_out:
|
||||
talloc_free(local_params);
|
||||
if (config->file_local_mode)
|
||||
m_config_leave_file_local(config);
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int mp_msg_levels[];
|
||||
|
@ -24,9 +24,9 @@
|
||||
struct playlist;
|
||||
struct m_config;
|
||||
|
||||
bool m_config_parse_mp_command_line(struct m_config *config,
|
||||
struct playlist *files,
|
||||
int argc, char **argv);
|
||||
int m_config_parse_mp_command_line(struct m_config *config,
|
||||
struct playlist *files,
|
||||
int argc, char **argv);
|
||||
void m_config_preparse_command_line(struct m_config *config,
|
||||
int argc, char **argv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user