本文整理汇总了C++中OPT_BOOL函数的典型用法代码示例。如果您正苦于以下问题:C++ OPT_BOOL函数的具体用法?C++ OPT_BOOL怎么用?C++ OPT_BOOL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OPT_BOOL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_shortlog
int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
static struct shortlog log;
static struct rev_info rev;
int nongit = !startup_info->have_repository;
static const struct option options[] = {
OPT_BOOL('n', "numbered", &log.sort_by_number,
N_("sort output according to the number of commits per author")),
OPT_BOOL('s', "summary", &log.summary,
N_("Suppress commit descriptions, only provides commit count")),
OPT_BOOL('e', "email", &log.email,
N_("Show the email address of each author")),
{ OPTION_CALLBACK, 'w', NULL, &log, N_("w[,i1[,i2]]"),
N_("Linewrap output"), PARSE_OPT_OPTARG, &parse_wrap_args },
OPT_END(),
};
struct parse_opt_ctx_t ctx;
git_config(git_default_config, NULL);
shortlog_init(&log);
init_revisions(&rev, prefix);
parse_options_start(&ctx, argc, argv, prefix, options,
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0);
for (;;) {
switch (parse_options_step(&ctx, options, shortlog_usage)) {
case PARSE_OPT_HELP:
exit(129);
case PARSE_OPT_DONE:
goto parse_done;
}
parse_revision_opt(&rev, &ctx, options, shortlog_usage);
}
parse_done:
argc = parse_options_end(&ctx);
if (setup_revisions(argc, argv, &rev, NULL) != 1) {
error(_("unrecognized argument: %s"), argv[1]);
usage_with_options(shortlog_usage, options);
}
log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
log.abbrev = rev.abbrev;
/* assume HEAD if from a tty */
if (!nongit && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev);
if (rev.pending.nr == 0) {
if (isatty(0))
fprintf(stderr, _("(reading log message from standard input)\n"));
read_from_stdin(&log);
}
else
get_from_rev(&rev, &log);
shortlog_output(&log);
return 0;
}
示例2: push_stash
static int push_stash(int argc, const char **argv, const char *prefix)
{
int keep_index = -1;
int patch_mode = 0;
int include_untracked = 0;
int quiet = 0;
const char *stash_msg = NULL;
struct pathspec ps;
struct option options[] = {
OPT_BOOL('k', "keep-index", &keep_index,
N_("keep index")),
OPT_BOOL('p', "patch", &patch_mode,
N_("stash in patch mode")),
OPT__QUIET(&quiet, N_("quiet mode")),
OPT_BOOL('u', "include-untracked", &include_untracked,
N_("include untracked files in stash")),
OPT_SET_INT('a', "all", &include_untracked,
N_("include ignore files"), 2),
OPT_STRING('m', "message", &stash_msg, N_("message"),
N_("stash message")),
OPT_END()
};
if (argc)
argc = parse_options(argc, argv, prefix, options,
git_stash_push_usage,
0);
parse_pathspec(&ps, 0, PATHSPEC_PREFER_FULL, prefix, argv);
return do_push_stash(ps, stash_msg, quiet, keep_index, patch_mode,
include_untracked);
}
示例3: cmd_push
int cmd_push(int argc, const char **argv, const char *prefix)
{
int flags = 0;
int tags = 0;
int rc;
const char *repo = NULL; /* default repository */
struct option options[] = {
OPT__VERBOSITY(&verbosity),
OPT_STRING( 0 , "repo", &repo, N_("repository"), N_("repository")),
OPT_BIT( 0 , "all", &flags, N_("push all refs"), TRANSPORT_PUSH_ALL),
OPT_BIT( 0 , "mirror", &flags, N_("mirror all refs"),
(TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
OPT_BOOL( 0, "delete", &deleterefs, N_("delete refs")),
OPT_BOOL( 0 , "tags", &tags, N_("push tags (can't be used with --all or --mirror)")),
OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN),
OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN),
OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE),
{ OPTION_CALLBACK, 0, "recurse-submodules", &flags, N_("check"),
N_("control recursive pushing of submodules"),
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),
OPT_BIT('u', "set-upstream", &flags, N_("set upstream for git pull/status"),
TRANSPORT_PUSH_SET_UPSTREAM),
OPT_BOOL(0, "progress", &progress, N_("force progress reporting")),
OPT_BIT(0, "prune", &flags, N_("prune locally removed refs"),
TRANSPORT_PUSH_PRUNE),
OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK),
OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
TRANSPORT_PUSH_FOLLOW_TAGS),
OPT_END()
};
packet_trace_identity("push");
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
die(_("--delete is incompatible with --all, --mirror and --tags"));
if (deleterefs && argc < 2)
die(_("--delete doesn't make sense without any refs"));
if (tags)
add_refspec("refs/tags/*");
if (argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
rc = do_push(repo, flags);
if (rc == -1)
usage_with_options(push_usage, options);
else
return rc;
}
示例4: cmd_main
int cmd_main(int argc, const char **argv)
{
const char *dir;
int strict = 0;
struct option options[] = {
OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
N_("quit after a single request/response exchange")),
OPT_BOOL(0, "advertise-refs", &advertise_refs,
N_("exit immediately after initial ref advertisement")),
OPT_BOOL(0, "strict", &strict,
N_("do not try <directory>/.git/ if <directory> is no Git directory")),
OPT_INTEGER(0, "timeout", &timeout,
N_("interrupt transfer after <n> seconds of inactivity")),
OPT_END()
};
packet_trace_identity("upload-pack");
check_replace_refs = 0;
argc = parse_options(argc, argv, NULL, options, upload_pack_usage, 0);
if (argc != 1)
usage_with_options(upload_pack_usage, options);
if (timeout)
daemon_mode = 1;
setup_path();
dir = argv[0];
if (!enter_repo(dir, strict))
die("'%s' does not appear to be a git repository", dir);
git_config(upload_pack_config, NULL);
switch (determine_protocol_version_server()) {
case protocol_v1:
/*
* v1 is just the original protocol with a version string,
* so just fall through after writing the version string.
*/
if (advertise_refs || !stateless_rpc)
packet_write_fmt(1, "version 1\n");
/* fallthrough */
case protocol_v0:
upload_pack();
break;
case protocol_unknown_version:
BUG("unknown protocol version");
}
return 0;
}
示例5: cmd_list
int cmd_list(int argc, const char **argv)
{
const char *program_usage_string = _(
"& list [options]"
);
int opt_not_reported = 0;
int opt_detailed = 0;
int opt_since = 0;
int opt_until = 0;
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_BOOL('n', "not-reported" , &opt_not_reported, _("List only not-reported problems")),
/* deprecate -d option with --pretty=full*/
OPT_BOOL('d', "detailed" , &opt_detailed, _("Show detailed report")),
OPT_INTEGER('s', "since" , &opt_since, _("List only the problems more recent than specified timestamp")),
OPT_INTEGER('u', "until" , &opt_until, _("List only the problems older than specified timestamp")),
OPT_END()
};
parse_opts(argc, (char **)argv, program_options, program_usage_string);
vector_of_problem_data_t *ci = fetch_crash_infos();
if (ci == NULL)
return 1;
g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_LAST_OCCURRENCE);
#if SUGGEST_AUTOREPORTING != 0
const bool output =
#endif
print_crash_list(ci, opt_detailed, opt_not_reported, opt_since, opt_until, CD_TEXT_ATT_SIZE_BZ);
free_vector_of_problem_data(ci);
#if SUGGEST_AUTOREPORTING != 0
load_abrt_conf();
if (!g_settings_autoreporting)
{
if (output)
putc('\n', stderr);
fprintf(stderr, _("The Autoreporting feature is disabled. Please consider enabling it by issuing\n"
"'abrt-auto-reporting enabled' as a user with root privileges\n"));
}
#endif
return 0;
}
示例6: cmd_interpret_trailers
int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
{
int trim_empty = 0;
struct string_list trailers = STRING_LIST_INIT_DUP;
struct option options[] = {
OPT_BOOL(0, "trim-empty", &trim_empty, N_("trim empty trailers")),
OPT_STRING_LIST(0, "trailer", &trailers, N_("trailer"),
N_("trailer(s) to add")),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options,
git_interpret_trailers_usage, 0);
if (argc) {
int i;
for (i = 0; i < argc; i++)
process_trailers(argv[i], trim_empty, &trailers);
} else
process_trailers(NULL, trim_empty, &trailers);
string_list_clear(&trailers, 0);
return 0;
}
示例7: list
static int list(int ac, const char **av, const char *prefix)
{
int porcelain = 0;
struct option options[] = {
OPT_BOOL(0, "porcelain", &porcelain, N_("machine-readable output")),
OPT_END()
};
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
if (ac)
usage_with_options(worktree_usage, options);
else {
struct worktree **worktrees = get_worktrees(GWT_SORT_LINKED);
int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i;
if (!porcelain)
measure_widths(worktrees, &abbrev, &path_maxlen);
for (i = 0; worktrees[i]; i++) {
if (porcelain)
show_worktree_porcelain(worktrees[i]);
else
show_worktree(worktrees[i], path_maxlen, abbrev);
}
free_worktrees(worktrees);
}
return 0;
}
示例8: cmd_status
int cmd_status(int argc, const char **argv)
{
const char *program_usage_string = _(
"& status"
);
int opt_bare = 0; /* must be _int_, OPT_BOOL expects that! */
int opt_since = 0;
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_BOOL ('b', "bare", &opt_bare, _("Print only the problem count without any message")),
OPT_INTEGER('s', "since", &opt_since, _("Print only the problems more recent than specified timestamp")),
OPT_END()
};
parse_opts(argc, (char **)argv, program_options, program_usage_string);
unsigned int problem_count = count_problem_dirs(opt_since);
/* show only if there is at least 1 problem or user set the -v */
if (problem_count > 0 || g_verbose > 0)
{
if (opt_bare)
printf("%u", problem_count);
else
{
char *list_arg = opt_since ? xasprintf(" --since %d", opt_since) : xstrdup("");
printf(_("ABRT has detected %u problem(s). For more info run: abrt-cli list%s\n"), problem_count, list_arg);
free(list_arg);
}
}
return 0;
}
示例9: cmd_version
int cmd_version(int argc, const char **argv, const char *prefix)
{
int build_options = 0;
const char * const usage[] = {
N_("git version [<options>]"),
NULL
};
struct option options[] = {
OPT_BOOL(0, "build-options", &build_options,
"also print build options"),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options, usage, 0);
/*
* The format of this string should be kept stable for compatibility
* with external projects that rely on the output of "git version".
*
* Always show the version, even if other options are given.
*/
printf("git version %s\n", git_version_string);
if (build_options) {
printf("cpu: %s\n", GIT_HOST_CPU);
if (git_built_from_commit_string[0])
printf("built from commit: %s\n",
git_built_from_commit_string);
else
printf("no commit associated with this build\n");
printf("sizeof-long: %d\n", (int)sizeof(long));
/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
}
return 0;
}
示例10: main
int main(int argc, const char **argv)
{
const char *socket_path;
static const char *usage[] = {
"git-credential-cache--daemon [opts] <socket_path>",
NULL
};
int debug = 0;
const struct option options[] = {
OPT_BOOL(0, "debug", &debug,
N_("print debugging messages to stderr")),
OPT_END()
};
argc = parse_options(argc, argv, NULL, options, usage, 0);
socket_path = argv[0];
if (!socket_path)
usage_with_options(usage, options);
check_socket_directory(socket_path);
register_tempfile(&socket_file, socket_path);
serve_cache(socket_path, debug);
delete_tempfile(&socket_file);
return 0;
}
示例11: pop_stash
static int pop_stash(int argc, const char **argv, const char *prefix)
{
int ret;
int index = 0;
int quiet = 0;
struct stash_info info;
struct option options[] = {
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_BOOL(0, "index", &index,
N_("attempt to recreate the index")),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options,
git_stash_pop_usage, 0);
if (get_stash_info(&info, argc, argv))
return -1;
assert_stash_ref(&info);
if ((ret = do_apply_stash(prefix, &info, index, quiet)))
printf_ln(_("The stash entry is kept in case "
"you need it again."));
else
ret = do_drop_stash(prefix, &info, quiet);
free_stash_info(&info);
return ret;
}
示例12: cmd_symbolic_ref
int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
{
int quiet = 0;
const char *msg = NULL;
struct option options[] = {
OPT__QUIET(&quiet,
N_("suppress error message for non-symbolic (detached) refs")),
OPT_BOOL(0, "short", &shorten, N_("shorten ref output")),
OPT_STRING('m', NULL, &msg, N_("reason"), N_("reason of the update")),
OPT_END(),
};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options,
git_symbolic_ref_usage, 0);
if (msg &&!*msg)
die("Refusing to perform update with empty message");
switch (argc) {
case 1:
check_symref(argv[0], quiet);
break;
case 2:
if (!strcmp(argv[0], "HEAD") &&
prefixcmp(argv[1], "refs/"))
die("Refusing to point HEAD outside of refs/");
create_symref(argv[0], argv[1], msg);
break;
default:
usage_with_options(git_symbolic_ref_usage, options);
}
return 0;
}
示例13: cmd_prune
int cmd_prune(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
struct progress *progress = NULL;
const struct option options[] = {
OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
OPT__VERBOSE(&verbose, N_("report pruned objects")),
OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
OPT_EXPIRY_DATE(0, "expire", &expire,
N_("expire objects older than <time>")),
OPT_END()
};
char *s;
expire = TIME_MAX;
save_commit_buffer = 0;
check_replace_refs = 0;
ref_paranoia = 1;
init_revisions(&revs, prefix);
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
if (repository_format_precious_objects)
die(_("cannot prune in a precious-objects repo"));
while (argc--) {
struct object_id oid;
const char *name = *argv++;
if (!get_oid(name, &oid)) {
struct object *object = parse_object_or_die(&oid,
name);
add_pending_object(&revs, object, "");
}
else
die("unrecognized argument: %s", name);
}
if (show_progress == -1)
show_progress = isatty(2);
if (show_progress)
progress = start_progress_delay(_("Checking connectivity"), 0, 0, 2);
mark_reachable_objects(&revs, 1, expire, progress);
stop_progress(&progress);
for_each_loose_file_in_objdir(get_object_directory(), prune_object,
prune_cruft, prune_subdir, NULL);
prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);
remove_temporary_files(get_object_directory());
s = mkpathdup("%s/pack", get_object_directory());
remove_temporary_files(s);
free(s);
if (is_repository_shallow())
prune_shallow(show_only);
return 0;
}
示例14: cmd_merge_base
int cmd_merge_base(int argc, const char **argv, const char *prefix)
{
struct commit **rev;
int rev_nr = 0;
int show_all = 0;
int cmdmode = 0;
struct option options[] = {
OPT_BOOL('a', "all", &show_all, N_("output all common ancestors")),
OPT_CMDMODE(0, "octopus", &cmdmode,
N_("find ancestors for a single n-way merge"), 'o'),
OPT_CMDMODE(0, "independent", &cmdmode,
N_("list revs not reachable from others"), 'r'),
OPT_CMDMODE(0, "is-ancestor", &cmdmode,
N_("is the first one ancestor of the other?"), 'a'),
OPT_CMDMODE(0, "fork-point", &cmdmode,
N_("find where <commit> forked from reflog of <ref>"), 'f'),
OPT_END()
};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, merge_base_usage, 0);
if (cmdmode == 'a') {
if (argc < 2)
usage_with_options(merge_base_usage, options);
if (show_all)
die("--is-ancestor cannot be used with --all");
return handle_is_ancestor(argc, argv);
}
if (cmdmode == 'r' && show_all)
die("--independent cannot be used with --all");
if (cmdmode == 'o')
return handle_octopus(argc, argv, show_all);
if (cmdmode == 'r')
return handle_independent(argc, argv);
if (cmdmode == 'f') {
if (argc < 1 || 2 < argc)
usage_with_options(merge_base_usage, options);
return handle_fork_point(argc, argv);
}
if (argc < 2)
usage_with_options(merge_base_usage, options);
ALLOC_ARRAY(rev, argc);
while (argc-- > 0)
rev[rev_nr++] = get_commit_reference(*argv++);
return show_merge_base(rev, rev_nr, show_all);
}
示例15: save_stash
static int save_stash(int argc, const char **argv, const char *prefix)
{
int keep_index = -1;
int patch_mode = 0;
int include_untracked = 0;
int quiet = 0;
int ret = 0;
const char *stash_msg = NULL;
struct pathspec ps;
struct strbuf stash_msg_buf = STRBUF_INIT;
struct option options[] = {
OPT_BOOL('k', "keep-index", &keep_index,
N_("keep index")),
OPT_BOOL('p', "patch", &patch_mode,
N_("stash in patch mode")),
OPT__QUIET(&quiet, N_("quiet mode")),
OPT_BOOL('u', "include-untracked", &include_untracked,
N_("include untracked files in stash")),
OPT_SET_INT('a', "all", &include_untracked,
N_("include ignore files"), 2),
OPT_STRING('m', "message", &stash_msg, "message",
N_("stash message")),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options,
git_stash_save_usage,
PARSE_OPT_KEEP_DASHDASH);
if (argc)
stash_msg = strbuf_join_argv(&stash_msg_buf, argc, argv, ' ');
memset(&ps, 0, sizeof(ps));
ret = do_push_stash(ps, stash_msg, quiet, keep_index,
patch_mode, include_untracked);
strbuf_release(&stash_msg_buf);
return ret;
}