本文整理汇总了C++中parser_t::current_filename方法的典型用法代码示例。如果您正苦于以下问题:C++ parser_t::current_filename方法的具体用法?C++ parser_t::current_filename怎么用?C++ parser_t::current_filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser_t
的用法示例。
在下文中一共展示了parser_t::current_filename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: builtin_status
/// The status builtin. Gives various status information on fish.
int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wchar_t *cmd = argv[0];
int argc = builtin_count_args(argv);
status_cmd_opts_t opts;
int optind;
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
if (retval != STATUS_CMD_OK) return retval;
if (opts.print_help) {
builtin_print_help(parser, streams, cmd, streams.out);
return STATUS_CMD_OK;
}
// If a status command hasn't already been specified via a flag check the first word.
// Note that this can be simplified after we eliminate allowing subcommands as flags.
if (optind < argc) {
status_cmd_t subcmd = str_to_enum(argv[optind], status_enum_map, status_enum_map_len);
if (subcmd != STATUS_UNDEF) {
if (!set_status_cmd(cmd, opts, subcmd, streams)) {
return STATUS_CMD_ERROR;
}
optind++;
} else {
streams.err.append_format(BUILTIN_ERR_INVALID_SUBCMD, cmd, argv[1]);
return STATUS_INVALID_ARGS;
}
}
// Every argument that we haven't consumed already is an argument for a subcommand.
const wcstring_list_t args(argv + optind, argv + argc);
switch (opts.status_cmd) {
case STATUS_UNDEF: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
if (is_login) {
streams.out.append_format(_(L"This is a login shell\n"));
} else {
streams.out.append_format(_(L"This is not a login shell\n"));
}
streams.out.append_format(
_(L"Job control: %ls\n"),
job_control_mode == JOB_CONTROL_INTERACTIVE
? _(L"Only on interactive jobs")
: (job_control_mode == JOB_CONTROL_NONE ? _(L"Never") : _(L"Always")));
streams.out.append(parser.stack_trace());
break;
}
case STATUS_SET_JOB_CONTROL: {
if (opts.new_job_control_mode != -1) {
// Flag form was used.
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
} else {
if (args.size() != 1) {
const wchar_t *subcmd_str = enum_to_str(opts.status_cmd, status_enum_map);
streams.err.append_format(BUILTIN_ERR_ARG_COUNT2, cmd, subcmd_str, 1,
args.size());
return STATUS_INVALID_ARGS;
}
opts.new_job_control_mode = job_control_str_to_mode(args[0].c_str(), cmd, streams);
if (opts.new_job_control_mode == -1) {
return STATUS_CMD_ERROR;
}
}
job_control_mode = opts.new_job_control_mode;
break;
}
case STATUS_FEATURES: {
print_features(streams);
break;
}
case STATUS_TEST_FEATURE: {
if (args.size() != 1) {
const wchar_t *subcmd_str = enum_to_str(opts.status_cmd, status_enum_map);
streams.err.append_format(BUILTIN_ERR_ARG_COUNT2, cmd, subcmd_str, 1, args.size());
return STATUS_INVALID_ARGS;
}
const auto *metadata = features_t::metadata_for(args.front().c_str());
if (!metadata) {
retval = TEST_FEATURE_NOT_RECOGNIZED;
} else {
retval = feature_test(metadata->flag) ? TEST_FEATURE_ON : TEST_FEATURE_OFF;
}
break;
}
case STATUS_FILENAME: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
const wchar_t *fn = parser.current_filename();
if (!fn) fn = _(L"Standard input");
streams.out.append_format(L"%ls\n", fn);
break;
}
case STATUS_FUNCTION: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
const wchar_t *fn = parser.get_function_name(opts.level);
if (!fn) fn = _(L"Not a function");
//.........这里部分代码省略.........