mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 13:57:17 +08:00
Remove print_hints from builtin_missing_argument and builtin_unknown_option
The print_hints variable was always false, so just remove it. This caused a cascade of other changes where the parser_t variable becomes unused, so remove it from the call sites. No functional change expected here.
This commit is contained in:
parent
285b0602e4
commit
8a50d47a46
|
@ -109,7 +109,7 @@ static const wchar_t *const short_options = L"+:h";
|
|||
static const struct woption long_options[] = {{L"help", no_argument, 'h'}, {}};
|
||||
|
||||
int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int argc,
|
||||
const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -120,11 +120,11 @@ int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -162,17 +162,12 @@ void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wch
|
|||
}
|
||||
|
||||
/// Perform error reporting for encounter with unknown option.
|
||||
void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||
const wchar_t *opt, bool print_hints) {
|
||||
void builtin_unknown_option(io_streams_t &streams, const wchar_t *cmd, const wchar_t *opt) {
|
||||
streams.err.append_format(BUILTIN_ERR_UNKNOWN, cmd, opt);
|
||||
if (print_hints) {
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform error reporting for encounter with missing argument.
|
||||
void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||
const wchar_t *opt, bool print_hints) {
|
||||
void builtin_missing_argument(io_streams_t &streams, const wchar_t *cmd, const wchar_t *opt) {
|
||||
if (opt[0] == L'-' && opt[1] != L'-') {
|
||||
// if c in -qc '-qc' is missing the argument, now opt is just 'c'
|
||||
opt += std::wcslen(opt) - 1;
|
||||
|
@ -180,10 +175,6 @@ void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wch
|
|||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, wcstring(L"-").append(opt).c_str());
|
||||
} else
|
||||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt);
|
||||
|
||||
if (print_hints) {
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the backtrace and call for help that we use at the end of error messages.
|
||||
|
@ -205,7 +196,7 @@ static maybe_t<int> builtin_generic(parser_t &parser, io_streams_t &streams, con
|
|||
int argc = builtin_count_args(argv);
|
||||
help_only_cmd_opts_t opts;
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -91,11 +91,9 @@ void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wch
|
|||
wcstring *error_message = nullptr);
|
||||
int builtin_count_args(const wchar_t *const *argv);
|
||||
|
||||
void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||
const wchar_t *opt, bool print_hints = true);
|
||||
void builtin_unknown_option(io_streams_t &streams, const wchar_t *cmd, const wchar_t *opt);
|
||||
|
||||
void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||
const wchar_t *opt, bool print_hints = true);
|
||||
void builtin_missing_argument(io_streams_t &streams, const wchar_t *cmd, const wchar_t *opt);
|
||||
|
||||
void builtin_print_error_trailer(parser_t &parser, output_stream_t &b, const wchar_t *cmd);
|
||||
|
||||
|
@ -105,5 +103,5 @@ struct help_only_cmd_opts_t {
|
|||
bool print_help = false;
|
||||
};
|
||||
int parse_help_only_cmd_opts(help_only_cmd_opts_t &opts, int *optind, int argc,
|
||||
const wchar_t **argv, parser_t &parser, io_streams_t &streams);
|
||||
const wchar_t **argv, io_streams_t &streams);
|
||||
#endif
|
||||
|
|
|
@ -381,7 +381,7 @@ maybe_t<int> builtin_abbr(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,13 +405,11 @@ static int parse_cmd_opts(argparse_cmd_opts_t &opts, int *optind, //!OCLINT(hig
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1],
|
||||
/* print_hints */ false);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1],
|
||||
/* print_hints */ false);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -573,8 +571,7 @@ static int argparse_parse_flags(parser_t &parser, argparse_cmd_opts_t &opts,
|
|||
wgetopter_t w;
|
||||
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, &long_idx)) != -1) {
|
||||
if (opt == ':') {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1],
|
||||
false /* print_hints */);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
} else if (opt == '?') {
|
||||
// It's not a recognized flag. See if it's an implicit int flag.
|
||||
|
|
|
@ -48,7 +48,7 @@ maybe_t<int> builtin_bg(parser_t &parser, io_streams_t &streams, const wchar_t *
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -343,7 +343,7 @@ void builtin_bind_t::list_modes(io_streams_t &streams) {
|
|||
}
|
||||
|
||||
static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
static const wchar_t *const short_options = L":aehkKfM:Lm:s";
|
||||
static const struct woption long_options[] = {{L"all", no_argument, 'a'},
|
||||
|
@ -424,11 +424,11 @@ static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -452,7 +452,7 @@ maybe_t<int> builtin_bind_t::builtin_bind(parser_t &parser, io_streams_t &stream
|
|||
this->opts = &opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.list_modes) {
|
||||
|
|
|
@ -23,7 +23,7 @@ struct block_cmd_opts_t {
|
|||
};
|
||||
|
||||
static int parse_cmd_opts(block_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
static const wchar_t *const short_options = L":eghl";
|
||||
static const struct woption long_options[] = {{L"erase", no_argument, 'e'},
|
||||
|
@ -53,11 +53,11 @@ static int parse_cmd_opts(block_cmd_opts_t &opts, int *optind, //!OCLINT(high n
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -77,7 +77,7 @@ maybe_t<int> builtin_block(parser_t &parser, io_streams_t &streams, const wchar_
|
|||
block_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -24,7 +24,7 @@ static const struct woption long_options[] = {
|
|||
{L"help", no_argument, 'h'}, {L"names", no_argument, 'n'}, {L"query", no_argument, 'q'}, {}};
|
||||
|
||||
static int parse_cmd_opts(builtin_cmd_opts_t &opts, int *optind, int argc, const wchar_t **argv,
|
||||
parser_t &parser, io_streams_t &streams) {
|
||||
io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -43,11 +43,11 @@ static int parse_cmd_opts(builtin_cmd_opts_t &opts, int *optind, int argc, const
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -69,7 +69,7 @@ maybe_t<int> builtin_builtin(parser_t &parser, io_streams_t &streams, const wcha
|
|||
builtin_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -31,7 +31,7 @@ maybe_t<int> builtin_cd(parser_t &parser, io_streams_t &streams, const wchar_t *
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -28,7 +28,7 @@ static const struct woption long_options[] = {
|
|||
{L"query", no_argument, 'q'}, {L"search", no_argument, 's'}, {}};
|
||||
|
||||
static int parse_cmd_opts(command_cmd_opts_t &opts, int *optind, int argc, const wchar_t **argv,
|
||||
parser_t &parser, io_streams_t &streams) {
|
||||
io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -52,11 +52,11 @@ static int parse_cmd_opts(command_cmd_opts_t &opts, int *optind, int argc, const
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -77,7 +77,7 @@ maybe_t<int> builtin_command(parser_t &parser, io_streams_t &streams, const wcha
|
|||
command_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -268,11 +268,11 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, const
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -293,7 +293,7 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, const
|
|||
}
|
||||
|
||||
if (argc == w.woptind) {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[0]);
|
||||
builtin_missing_argument(streams, cmd, argv[0]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
|
|
|
@ -294,11 +294,11 @@ maybe_t<int> builtin_complete(parser_t &parser, io_streams_t &streams, const wch
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -369,7 +369,7 @@ maybe_t<int> builtin_complete(parser_t &parser, io_streams_t &streams, const wch
|
|||
if (!state.initialized) {
|
||||
// This corresponds to using 'complete -C' in non-interactive mode.
|
||||
// See #2361 .
|
||||
builtin_missing_argument(parser, streams, cmd, L"-C");
|
||||
builtin_missing_argument(streams, cmd, L"-C");
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
do_complete_param = std::move(state.text);
|
||||
|
|
|
@ -22,7 +22,7 @@ static const struct woption long_options[] = {
|
|||
{L"help", no_argument, 'h'}, {L"index", no_argument, 'i'}, {}};
|
||||
|
||||
static int parse_cmd_opts(contains_cmd_opts_t &opts, int *optind, int argc, const wchar_t **argv,
|
||||
parser_t &parser, io_streams_t &streams) {
|
||||
io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -37,11 +37,11 @@ static int parse_cmd_opts(contains_cmd_opts_t &opts, int *optind, int argc, cons
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -62,7 +62,7 @@ maybe_t<int> builtin_contains(parser_t &parser, io_streams_t &streams, const wch
|
|||
contains_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -48,7 +48,7 @@ maybe_t<int> builtin_disown(parser_t &parser, io_streams_t &streams, const wchar
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -49,7 +49,7 @@ static int parse_cmd_opts(echo_cmd_opts_t &opts, int *optind, int argc, const wc
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
|
|
|
@ -20,7 +20,7 @@ maybe_t<int> builtin_emit(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -34,7 +34,7 @@ static int parse_cmd_opts(exit_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
|
|
|
@ -35,7 +35,7 @@ maybe_t<int> builtin_fg(parser_t &parser, io_streams_t &streams, const wchar_t *
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -178,11 +178,11 @@ static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(hig
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -55,7 +55,7 @@ static const struct woption long_options[] = {{L"erase", no_argument, 'e'},
|
|||
{}};
|
||||
|
||||
static int parse_cmd_opts(functions_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -111,11 +111,11 @@ static int parse_cmd_opts(functions_cmd_opts_t &opts, int *optind, //!OCLINT(hi
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -196,7 +196,7 @@ maybe_t<int> builtin_functions(parser_t &parser, io_streams_t &streams, const wc
|
|||
functions_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -103,7 +103,7 @@ static bool check_for_unexpected_hist_args(const history_cmd_opts_t &opts, const
|
|||
}
|
||||
|
||||
static int parse_cmd_opts(history_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -184,14 +184,14 @@ static int parse_cmd_opts(history_cmd_opts_t &opts, int *optind, //!OCLINT(high
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
// Try to parse it as a number; e.g., "-123".
|
||||
opts.max_items = fish_wcstol(argv[w.woptind - 1] + 1);
|
||||
if (errno) {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
w.nextchar = nullptr;
|
||||
|
@ -214,7 +214,7 @@ maybe_t<int> builtin_history(parser_t &parser, io_streams_t &streams, const wcha
|
|||
history_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -160,11 +160,11 @@ maybe_t<int> builtin_jobs(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -42,7 +42,7 @@ static const struct woption long_options[] = {{L"scale", required_argument, 's'}
|
|||
{}};
|
||||
|
||||
static int parse_cmd_opts(math_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = L"math";
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -83,7 +83,7 @@ static int parse_cmd_opts(math_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
|
@ -279,7 +279,7 @@ maybe_t<int> builtin_math(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
// Is this really the right way to handle no expression present?
|
||||
// if (argc == 0) return STATUS_CMD_OK;
|
||||
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -463,8 +463,7 @@ static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, co
|
|||
if (retval != STATUS_CMD_OK) return retval;
|
||||
} else if (opt == ':') {
|
||||
streams.err.append(L"path ");
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1],
|
||||
false /* print_hints */);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
} else if (opt == '?') {
|
||||
path_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
|
|
|
@ -43,7 +43,7 @@ maybe_t<int> builtin_pwd(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
builtin_print_help(parser, streams, cmd);
|
||||
return STATUS_CMD_OK;
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -33,7 +33,7 @@ maybe_t<int> builtin_random(parser_t &parser, io_streams_t &streams, const wchar
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -177,11 +177,11 @@ static int parse_cmd_opts(read_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -28,7 +28,7 @@ static const struct woption long_options[] = {
|
|||
{L"no-symlinks", no_argument, 's'}, {L"help", no_argument, 'h'}, {}};
|
||||
|
||||
static int parse_cmd_opts(realpath_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -43,11 +43,11 @@ static int parse_cmd_opts(realpath_cmd_opts_t &opts, int *optind, //!OCLINT(hig
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -68,7 +68,7 @@ maybe_t<int> builtin_realpath(parser_t &parser, io_streams_t &streams, const wch
|
|||
int argc = builtin_count_args(argv);
|
||||
int optind;
|
||||
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -37,7 +37,7 @@ static int parse_cmd_opts(return_cmd_opts_t &opts, int *optind, //!OCLINT(high
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
|
|
|
@ -81,7 +81,7 @@ static const struct woption long_options[] = {{L"export", no_argument, 'x'},
|
|||
_(L"%ls: successfully set universal '%ls'; but a global by that name shadows it\n")
|
||||
|
||||
static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
|
||||
int opt;
|
||||
|
@ -157,7 +157,7 @@ static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncs
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
|
@ -175,7 +175,7 @@ static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncs
|
|||
}
|
||||
}
|
||||
}
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -814,7 +814,7 @@ maybe_t<int> builtin_set(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
set_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
|
|
@ -163,7 +163,7 @@ maybe_t<int> builtin_set_color(parser_t &parser, io_streams_t &streams, const wc
|
|||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, L"set_color", argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, L"set_color", argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -32,7 +32,7 @@ maybe_t<int> builtin_source(parser_t &parser, io_streams_t &streams, const wchar
|
|||
help_only_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -166,7 +166,7 @@ static void print_features(io_streams_t &streams) {
|
|||
}
|
||||
|
||||
static int parse_cmd_opts(status_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, const wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
int argc, const wchar_t **argv, io_streams_t &streams) {
|
||||
const wchar_t *cmd = argv[0];
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
@ -266,11 +266,11 @@ static int parse_cmd_opts(status_cmd_opts_t &opts, int *optind, //!OCLINT(high
|
|||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -290,7 +290,7 @@ maybe_t<int> builtin_status(parser_t &parser, io_streams_t &streams, const wchar
|
|||
status_cmd_opts_t opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.print_help) {
|
||||
|
|
|
@ -657,8 +657,7 @@ static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, co
|
|||
if (retval != STATUS_CMD_OK) return retval;
|
||||
} else if (opt == ':') {
|
||||
streams.err.append(L"string "); // clone of string_error
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1],
|
||||
false /* print_hints */);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
} else if (opt == '?') {
|
||||
string_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
|
|
|
@ -379,11 +379,11 @@ maybe_t<int> builtin_ulimit(parser_t &parser, io_streams_t &streams, const wchar
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -150,11 +150,11 @@ maybe_t<int> builtin_wait(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
print_help = true;
|
||||
break;
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_missing_argument(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
builtin_unknown_option(streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user