本文整理汇总了C++中parser_t::detect_errors_in_argument_list方法的典型用法代码示例。如果您正苦于以下问题:C++ parser_t::detect_errors_in_argument_list方法的具体用法?C++ parser_t::detect_errors_in_argument_list怎么用?C++ parser_t::detect_errors_in_argument_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser_t
的用法示例。
在下文中一共展示了parser_t::detect_errors_in_argument_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: builtin_complete
//.........这里部分代码省略.........
if (!res)
{
if (condition && wcslen(condition))
{
const wcstring condition_string = condition;
parse_error_list_t errors;
if (parse_util_detect_errors(condition_string, &errors, false /* do not accept incomplete */))
{
streams.err.append_format(L"%ls: Condition '%ls' contained a syntax error",
argv[0],
condition);
for (size_t i=0; i < errors.size(); i++)
{
streams.err.append_format(L"\n%s: ", argv[0]);
streams.err.append(errors.at(i).describe(condition_string));
}
res = true;
}
}
}
if (!res)
{
if (comp && wcslen(comp))
{
wcstring prefix;
if (argv[0])
{
prefix.append(argv[0]);
prefix.append(L": ");
}
wcstring err_text;
if (parser.detect_errors_in_argument_list(comp, &err_text, prefix.c_str()))
{
streams.err.append_format(L"%ls: Completion '%ls' contained a syntax error\n",
argv[0],
comp);
streams.err.append(err_text);
streams.err.push_back(L'\n');
res = true;
}
}
}
if (!res)
{
if (do_complete)
{
const wchar_t *token;
parse_util_token_extent(do_complete_param.c_str(), do_complete_param.size(), &token, 0, 0, 0);
/* Create a scoped transient command line, so that bulitin_commandline will see our argument, not the reader buffer */
builtin_commandline_scoped_transient_t temp_buffer(do_complete_param);
if (recursion_level < 1)
{
recursion_level++;
std::vector<completion_t> comp;
complete(do_complete_param, comp, COMPLETION_REQUEST_DEFAULT);
for (size_t i=0; i< comp.size() ; i++)
{
const completion_t &next = comp.at(i);
示例2: builtin_complete
//.........这里部分代码省略.........
DIE("unexpected retval from wgetopt_long");
break;
}
}
}
if (w.woptind != argc) {
streams.err.append_format(BUILTIN_ERR_TOO_MANY_ARGUMENTS, cmd);
builtin_print_error_trailer(parser, streams.err, cmd);
return STATUS_INVALID_ARGS;
}
if (condition && std::wcslen(condition)) {
const wcstring condition_string = condition;
parse_error_list_t errors;
if (parse_util_detect_errors(condition_string, &errors,
false /* do not accept incomplete */)) {
streams.err.append_format(L"%ls: Condition '%ls' contained a syntax error", cmd,
condition);
for (size_t i = 0; i < errors.size(); i++) {
streams.err.append_format(L"\n%s: ", cmd);
streams.err.append(errors.at(i).describe(condition_string));
}
return STATUS_CMD_ERROR;
}
}
if (comp && std::wcslen(comp)) {
wcstring prefix;
prefix.append(cmd);
prefix.append(L": ");
wcstring err_text;
if (parser.detect_errors_in_argument_list(comp, &err_text, prefix.c_str())) {
streams.err.append_format(L"%ls: Completion '%ls' contained a syntax error\n", cmd,
comp);
streams.err.append(err_text);
streams.err.push_back(L'\n');
return STATUS_CMD_ERROR;
}
}
if (do_complete) {
const wchar_t *token;
parse_util_token_extent(do_complete_param.c_str(), do_complete_param.size(), &token, 0, 0,
0);
// Create a scoped transient command line, so that bulitin_commandline will see our
// argument, not the reader buffer.
builtin_commandline_scoped_transient_t temp_buffer(do_complete_param);
if (recursion_level < 1) {
recursion_level++;
std::vector<completion_t> comp;
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH, parser.vars());
for (size_t i = 0; i < comp.size(); i++) {
const completion_t &next = comp.at(i);
// Make a fake commandline, and then apply the completion to it.
const wcstring faux_cmdline = token;
size_t tmp_cursor = faux_cmdline.size();
wcstring faux_cmdline_with_completion = completion_apply_to_command_line(
next.completion, next.flags, faux_cmdline, &tmp_cursor, false);