• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OPT_GROUP函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OPT_GROUP函数的典型用法代码示例。如果您正苦于以下问题:C++ OPT_GROUP函数的具体用法?C++ OPT_GROUP怎么用?C++ OPT_GROUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OPT_GROUP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, const char **argv)
{
	const char *usage[] = {
		"test-parse-options <options>",
		NULL
	};
	struct option options[] = {
		OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"),
		OPT_INTEGER('i', "integer", &integer, "get a integer"),
		OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
		OPT_GROUP("string options"),
		OPT_STRING('s', "string", &string, "string", "get a string"),
		OPT_STRING(0, "string2", &string, "str", "get another string"),
		OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
		OPT_STRING('o', NULL, &string, "str", "get another string"),
		OPT_GROUP("magic arguments"),
		OPT_ARGUMENT("quux", "means --quux"),
		OPT_END(),
	};
	int i;

	argc = parse_options(argc, argv, options, usage, 0);

	printf("boolean: %d\n", boolean);
	printf("integer: %d\n", integer);
	printf("string: %s\n", string ? string : "(not set)");

	for (i = 0; i < argc; i++)
		printf("arg %02d: %s\n", i, argv[i]);

	return 0;
}
开发者ID:Jatinpurohit,项目名称:git,代码行数:32,代码来源:test-parse-options.c


示例2: main

int main(int argc, const char **argv)
{
	const char *prefix = "prefix/";
	const char *usage[] = {
		"test-parse-options <options>",
		NULL
	};
	struct option options[] = {
		OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"),
		OPT_BIT('4', "or4", &boolean,
			"bitwise-or boolean with ...0100", 4),
		OPT_NEGBIT(0, "neg-or4", &boolean, "same as --no-or4", 4),
		OPT_GROUP(""),
		OPT_INTEGER('i', "integer", &integer, "get a integer"),
		OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
		OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
		OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
		OPT_CALLBACK('L', "length", &integer, "str",
			"get length of <str>", length_callback),
		OPT_FILENAME('F', "file", &file, "set file to <FILE>"),
		OPT_GROUP("String options"),
		OPT_STRING('s', "string", &string, "string", "get a string"),
		OPT_STRING(0, "string2", &string, "str", "get another string"),
		OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
		OPT_STRING('o', NULL, &string, "str", "get another string"),
		OPT_SET_PTR(0, "default-string", &string,
			"set string to default", (unsigned long)"default"),
		OPT_GROUP("Magic arguments"),
		OPT_ARGUMENT("quux", "means --quux"),
		OPT_NUMBER_CALLBACK(&integer, "set integer to NUM",
			number_callback),
		{ OPTION_BOOLEAN, '+', NULL, &boolean, NULL, "same as -b",
		  PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH },
		OPT_GROUP("Standard options"),
		OPT__ABBREV(&abbrev),
		OPT__VERBOSE(&verbose),
		OPT__DRY_RUN(&dry_run),
		OPT__QUIET(&quiet),
		OPT_END(),
	};
	int i;

	argc = parse_options(argc, argv, prefix, options, usage, 0);

	printf("boolean: %d\n", boolean);
	printf("integer: %u\n", integer);
	printf("timestamp: %lu\n", timestamp);
	printf("string: %s\n", string ? string : "(not set)");
	printf("abbrev: %d\n", abbrev);
	printf("verbose: %d\n", verbose);
	printf("quiet: %s\n", quiet ? "yes" : "no");
	printf("dry run: %s\n", dry_run ? "yes" : "no");
	printf("file: %s\n", file ? file : "(not set)");

	for (i = 0; i < argc; i++)
		printf("arg %02d: %s\n", i, argv[i]);

	return 0;
}
开发者ID:Fabiano-lr,项目名称:git,代码行数:59,代码来源:test-parse-options.c


示例3: main

/* 
 * This application substitues in the DNA sequence the outside ACGT chars by random ACGT symbols.
 */
int main(int argc, char *argv[]){
  uint32_t streamSize, index, seed = 0;
  uint8_t  value;
  char     *bases = "ACGT";
  BUF *Buffer;
  srand(seed);
  
  char *programName = argv[0];
  struct argparse_option options[] = {
        OPT_HELP(),
        OPT_GROUP("Basic options"),
        OPT_BUFF('<', "input.seq", "Input sequence file (stdin)"),
        OPT_BUFF('>', "output.seq", "Output sequence file (stdout)"),
        OPT_END(),
  };
  struct argparse argparse;

  char usage[250] = "\nExample: "; 
  strcat(usage, programName);
  strcat(usage, " < input.seq > output.seq\n");

  argparse_init(&argparse, options, NULL, programName, 0);
  argparse_describe(&argparse, "\nIt substitues in the DNA sequence the outside "
    "ACGT chars by random ACGT symbols.\nIt works in sequence file formats\n", usage);
  argc = argparse_parse(&argparse, argc, argv);

  if(argc != 0)
    argparse_help_cb(&argparse, options);

  Buffer = CreateBuffer(BUF_SIZE);

  while((streamSize = fread(Buffer->buf, 1, Buffer->size, stdin)))
    for(index = 0 ; index < streamSize ; ++index)
    {
      value = Buffer->buf[index];
      if(value == '\n')
        continue;
      RandIfExtra(value, bases);
    } 

  RemoveBuffer(Buffer); 
  return EXIT_SUCCESS;
}
开发者ID:pratas,项目名称:goose,代码行数:46,代码来源:RandSeqExtraChars.c


示例4: cmd_gidit

int cmd_gidit(int argc, const char **argv, const char *prefix)
{
	int flags = 0;
	int tags = 0, init = 0, verbose = 0, pushobj = 0, updatepl = 0, sign = 0,
		proj_init = 0, polist = 0, store_bundle = 0, get_bundle = 0, pobj_val = 0,
		create_bundle = 0;

	const char *basepath = NULL;
	const char *keyid = NULL;

	int rc;

	struct option options[] = {
		OPT__VERBOSE(&verbose),
		OPT_GROUP(""),
		OPT_BOOLEAN( 0 , "tags", &tags, "include tags"),
		OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
		OPT_STRING('u', NULL, &keyid, "key-id",
					"use another key to sign the tag"),
		OPT_BOOLEAN( 0 , "pushobj", &pushobj, "generate push object"),
		OPT_BOOLEAN( 0 , "verify-pobj", &pobj_val, "validate a given pushobject"),
		OPT_BOOLEAN( 0 , "create-bundle", &create_bundle, "validate a given pushobject"),
		OPT_GROUP(""),
		OPT_BOOLEAN( 0 , "updatepl", &updatepl, "Update push list"),
		OPT_STRING('b', NULL, &basepath, "base-path", "base-path for daemon"),
		OPT_BOOLEAN( 0 , "init", &init, "init gidit directory"),
		OPT_BOOLEAN( 0 , "proj-init", &proj_init, "init user's gidit project directory"),
		OPT_BOOLEAN( 0 , "polist", &polist, "Generate list of push objects"),
		OPT_BOOLEAN( 0 , "store-bundle", &store_bundle, "store a given bundle"),
		OPT_BOOLEAN( 0 , "get-bundle", &get_bundle, "get a bundle"),
		OPT_END()
	};

	git_config(git_gidit_config, NULL);

	argc = parse_options(argc, argv, options, gidit_usage, 0);

	if (keyid) {
		sign = 1;
		set_signingkey(keyid);
	} else if (sign) {
		if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
				sizeof(signingkey)) > sizeof(signingkey) - 1)
			return error("committer info too long.");
		char * bracket = strchr(signingkey, '>');
		if (bracket)
			bracket[1] = '\0';
	}

	if (tags)
		flags |= INCLUDE_TAGS;


	if (pushobj)
		return !!gidit_pushobj(stdout, signingkey, sign, flags);
	else if (pobj_val)
		return !!gidit_verify_pushobj(stdin, flags);
	else if (create_bundle)
		return !!gidit_gen_bundle(stdin, flags);

	if (!basepath)
		usage_with_options(gidit_usage, options);

	if (base_path_test(basepath))
		return -1;

	if (init)
		rc = gidit_init(basepath);
	else if (proj_init)
		rc = gidit_proj_init(stdin, basepath, flags);
	else if (updatepl)
		rc = gidit_update_pl(stdin, basepath, flags);
	else if (polist)
		rc = gidit_po_list(stdin, basepath, flags);
	else if (store_bundle)
		rc = gidit_store_bundle(stdin, basepath, flags);
	else if (get_bundle)
		rc = gidit_get_bundle(stdin, stdout, basepath, flags);
	else
		rc = -1;

	if (rc == -1)
		usage_with_options(gidit_usage, options);
	else
		return rc;
}
开发者ID:zhaoz,项目名称:gidit,代码行数:86,代码来源:builtin-gidit.c


示例5: cmd_commit

int cmd_commit(int argc, const char **argv, const char *prefix)
{
	static struct wt_status s;
	static struct option builtin_commit_options[] = {
		OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
		OPT__VERBOSE(&verbose, N_("show diff in commit message template")),

		OPT_GROUP(N_("Commit message options")),
		OPT_FILENAME('F', "file", &logfile, N_("read message from file")),
		OPT_STRING(0, "author", &force_author, N_("author"), N_("override author for commit")),
		OPT_STRING(0, "date", &force_date, N_("date"), N_("override date for commit")),
		OPT_CALLBACK('m', "message", &message, N_("message"), N_("commit message"), opt_parse_m),
		OPT_STRING('c', "reedit-message", &edit_message, N_("commit"), N_("reuse and edit message from specified commit")),
		OPT_STRING('C', "reuse-message", &use_message, N_("commit"), N_("reuse message from specified commit")),
		OPT_STRING(0, "fixup", &fixup_message, N_("commit"), N_("use autosquash formatted message to fixup specified commit")),
		OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")),
		OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")),
		OPT_BOOL('s', "signoff", &signoff, N_("add Signed-off-by:")),
		OPT_FILENAME('t', "template", &template_file, N_("use specified template file")),
		OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")),
		OPT_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")),
		OPT_BOOL(0, "status", &include_status, N_("include status in commit message template")),
		{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key id"),
		  N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
		/* end commit message options */

		OPT_GROUP(N_("Commit contents options")),
		OPT_BOOL('a', "all", &all, N_("commit all changed files")),
		OPT_BOOL('i', "include", &also, N_("add specified files to index for commit")),
		OPT_BOOL(0, "interactive", &interactive, N_("interactively add files")),
		OPT_BOOL('p', "patch", &patch_interactive, N_("interactively add changes")),
		OPT_BOOL('o', "only", &only, N_("commit only specified files")),
		OPT_BOOL('n', "no-verify", &no_verify, N_("bypass pre-commit hook")),
		OPT_BOOL(0, "dry-run", &dry_run, N_("show what would be committed")),
		OPT_SET_INT(0, "short", &status_format, N_("show status concisely"),
			    STATUS_FORMAT_SHORT),
		OPT_BOOL(0, "branch", &s.show_branch, N_("show branch information")),
		OPT_SET_INT(0, "porcelain", &status_format,
			    N_("machine-readable output"), STATUS_FORMAT_PORCELAIN),
		OPT_SET_INT(0, "long", &status_format,
			    N_("show status in long format (default)"),
			    STATUS_FORMAT_LONG),
		OPT_BOOL('z', "null", &s.null_termination,
			 N_("terminate entries with NUL")),
		OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
		OPT_BOOL(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")),
		{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
		/* end commit contents options */

		OPT_HIDDEN_BOOL(0, "allow-empty", &allow_empty,
				N_("ok to record an empty change")),
		OPT_HIDDEN_BOOL(0, "allow-empty-message", &allow_empty_message,
				N_("ok to record a change with an empty message")),

		OPT_END()
	};

	struct strbuf sb = STRBUF_INIT;
	struct strbuf author_ident = STRBUF_INIT;
	const char *index_file, *reflog_msg;
	char *nl;
	unsigned char sha1[20];
	struct ref_lock *ref_lock;
	struct commit_list *parents = NULL, **pptr = &parents;
	struct stat statbuf;
	struct commit *current_head = NULL;
	struct commit_extra_header *extra = NULL;

	if (argc == 2 && !strcmp(argv[1], "-h"))
		usage_with_options(builtin_commit_usage, builtin_commit_options);

	status_init_config(&s, git_commit_config);
	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
	s.colopts = 0;

	if (get_sha1("HEAD", sha1))
		current_head = NULL;
	else {
		current_head = lookup_commit_or_die(sha1, "HEAD");
		if (parse_commit(current_head))
			die(_("could not parse HEAD commit"));
	}
	argc = parse_and_validate_options(argc, argv, builtin_commit_options,
					  builtin_commit_usage,
					  prefix, current_head, &s);
	if (dry_run)
		return dry_run_commit(argc, argv, prefix, current_head, &s);
	index_file = prepare_index(argc, argv, prefix, current_head, 0);

	/* Set up everything for writing the commit object.  This includes
	   running hooks, writing the trees, and interacting with the user.  */
	if (!prepare_to_commit(index_file, prefix,
			       current_head, &s, &author_ident)) {
		rollback_index_files();
		return 1;
	}

	/* Determine parents */
	reflog_msg = getenv("GIT_REFLOG_ACTION");
	if (!current_head) {
//.........这里部分代码省略.........
开发者ID:AresDice,项目名称:git,代码行数:101,代码来源:commit.c


示例6: main

int main(int argc, char **argv)
{
    const char *prefix = "prefix/";
    const char *usage[] = {
        "test-parse-options <options>",
        NULL
    };
    struct string_list expect = STRING_LIST_INIT_NODUP;
    struct option options[] = {
        OPT_BOOL(0, "yes", &boolean, "get a boolean"),
        OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"),
        {   OPTION_SET_INT, 'B', "no-fear", &boolean, NULL,
            "be brave", PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1
        },
        OPT_COUNTUP('b', "boolean", &boolean, "increment by one"),
        OPT_BIT('4', "or4", &boolean,
        "bitwise-or boolean with ...0100", 4),
        OPT_NEGBIT(0, "neg-or4", &boolean, "same as --no-or4", 4),
        OPT_GROUP(""),
        OPT_INTEGER('i', "integer", &integer, "get a integer"),
        OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
        OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
        OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
        OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
        OPT_CALLBACK('L', "length", &integer, "str",
        "get length of <str>", length_callback),
        OPT_FILENAME('F', "file", &file, "set file to <file>"),
        OPT_GROUP("String options"),
        OPT_STRING('s', "string", &string, "string", "get a string"),
        OPT_STRING(0, "string2", &string, "str", "get another string"),
        OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
        OPT_STRING('o', NULL, &string, "str", "get another string"),
        OPT_NOOP_NOARG(0, "obsolete"),
        OPT_STRING_LIST(0, "list", &list, "str", "add str to list"),
        OPT_GROUP("Magic arguments"),
        OPT_ARGUMENT("quux", "means --quux"),
        OPT_NUMBER_CALLBACK(&integer, "set integer to NUM",
        number_callback),
        {   OPTION_COUNTUP, '+', NULL, &boolean, NULL, "same as -b",
            PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH
        },
        {   OPTION_COUNTUP, 0, "ambiguous", &ambiguous, NULL,
            "positive ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG
        },
        {   OPTION_COUNTUP, 0, "no-ambiguous", &ambiguous, NULL,
            "negative ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG
        },
        OPT_GROUP("Standard options"),
        OPT__ABBREV(&abbrev),
        OPT__VERBOSE(&verbose, "be verbose"),
        OPT__DRY_RUN(&dry_run, "dry run"),
        OPT__QUIET(&quiet, "be quiet"),
        OPT_CALLBACK(0, "expect", &expect, "string",
        "expected output in the variable dump",
        collect_expect),
        OPT_END(),
    };
    int i;
    int ret = 0;

    argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);

    if (length_cb.called) {
        const char *arg = length_cb.arg;
        int unset = length_cb.unset;
        show(&expect, &ret, "Callback: \"%s\", %d",
             (arg ? arg : "not set"), unset);
    }
    show(&expect, &ret, "boolean: %d", boolean);
    show(&expect, &ret, "integer: %d", integer);
    show(&expect, &ret, "magnitude: %lu", magnitude);
    show(&expect, &ret, "timestamp: %lu", timestamp);
    show(&expect, &ret, "string: %s", string ? string : "(not set)");
    show(&expect, &ret, "abbrev: %d", abbrev);
    show(&expect, &ret, "verbose: %d", verbose);
    show(&expect, &ret, "quiet: %d", quiet);
    show(&expect, &ret, "dry run: %s", dry_run ? "yes" : "no");
    show(&expect, &ret, "file: %s", file ? file : "(not set)");

    for (i = 0; i < list.nr; i++)
        show(&expect, &ret, "list: %s", list.items[i].string);

    for (i = 0; i < argc; i++)
        show(&expect, &ret, "arg %02d: %s", i, argv[i]);

    return ret;
}
开发者ID:yukino6223,项目名称:git,代码行数:87,代码来源:test-parse-options.c


示例7: parse_archive_args

static int parse_archive_args(int argc, const char **argv,
		const struct archiver **ar, struct archiver_args *args,
		const char *name_hint, int is_remote)
{
	const char *format = NULL;
	const char *base = NULL;
	const char *remote = NULL;
	const char *exec = NULL;
	const char *output = NULL;
	int compression_level = -1;
	int verbose = 0;
	int i;
	int list = 0;
	int worktree_attributes = 0;
	struct option opts[] = {
		OPT_GROUP(""),
		OPT_STRING(0, "format", &format, N_("fmt"), N_("archive format")),
		OPT_STRING(0, "prefix", &base, N_("prefix"),
			N_("prepend prefix to each pathname in the archive")),
		OPT_STRING('o', "output", &output, N_("file"),
			N_("write the archive to this file")),
		OPT_BOOL(0, "worktree-attributes", &worktree_attributes,
			N_("read .gitattributes in working directory")),
		OPT__VERBOSE(&verbose, N_("report archived files on stderr")),
		OPT__COMPR('0', &compression_level, N_("store only"), 0),
		OPT__COMPR('1', &compression_level, N_("compress faster"), 1),
		OPT__COMPR_HIDDEN('2', &compression_level, 2),
		OPT__COMPR_HIDDEN('3', &compression_level, 3),
		OPT__COMPR_HIDDEN('4', &compression_level, 4),
		OPT__COMPR_HIDDEN('5', &compression_level, 5),
		OPT__COMPR_HIDDEN('6', &compression_level, 6),
		OPT__COMPR_HIDDEN('7', &compression_level, 7),
		OPT__COMPR_HIDDEN('8', &compression_level, 8),
		OPT__COMPR('9', &compression_level, N_("compress better"), 9),
		OPT_GROUP(""),
		OPT_BOOL('l', "list", &list,
			N_("list supported archive formats")),
		OPT_GROUP(""),
		OPT_STRING(0, "remote", &remote, N_("repo"),
			N_("retrieve the archive from remote repository <repo>")),
		OPT_STRING(0, "exec", &exec, N_("command"),
			N_("path to the remote git-upload-archive command")),
		OPT_END()
	};

	argc = parse_options(argc, argv, NULL, opts, archive_usage, 0);

	if (remote)
		die("Unexpected option --remote");
	if (exec)
		die("Option --exec can only be used together with --remote");
	if (output)
		die("Unexpected option --output");

	if (!base)
		base = "";

	if (list) {
		for (i = 0; i < nr_archivers; i++)
			if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)
				printf("%s\n", archivers[i]->name);
		exit(0);
	}

	if (!format && name_hint)
		format = archive_format_from_filename(name_hint);
	if (!format)
		format = "tar";

	/* We need at least one parameter -- tree-ish */
	if (argc < 1)
		usage_with_options(archive_usage, opts);
	*ar = lookup_archiver(format);
	if (!*ar || (is_remote && !((*ar)->flags & ARCHIVER_REMOTE)))
		die("Unknown archive format '%s'", format);

	args->compression_level = Z_DEFAULT_COMPRESSION;
	if (compression_level != -1) {
		if ((*ar)->flags & ARCHIVER_WANT_COMPRESSION_LEVELS)
			args->compression_level = compression_level;
		else {
			die("Argument not supported for format '%s': -%d",
					format, compression_level);
		}
	}
	args->verbose = verbose;
	args->base = base;
	args->baselen = strlen(base);
	args->worktree_attributes = worktree_attributes;

	return argc;
}
开发者ID:B-Rich,项目名称:git,代码行数:92,代码来源:archive.c


示例8: ignore_removal_cb

static int addremove = ADDREMOVE_DEFAULT;
static int addremove_explicit = -1; /* unspecified */

static char *chmod_arg;

static int ignore_removal_cb(const struct option *opt, const char *arg, int unset)
{
	/* if we are told to ignore, we are not adding removals */
	*(int *)opt->value = !unset ? 0 : 1;
	return 0;
}

static struct option builtin_add_options[] = {
	OPT__DRY_RUN(&show_only, N_("dry run")),
	OPT__VERBOSE(&verbose, N_("be verbose")),
	OPT_GROUP(""),
	OPT_BOOL('i', "interactive", &add_interactive, N_("interactive picking")),
	OPT_BOOL('p', "patch", &patch_interactive, N_("select hunks interactively")),
	OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
	OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0),
	OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
	OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
	OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
	OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
	{ OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit,
	  NULL /* takes no arguments */,
	  N_("ignore paths removed in the working tree (same as --no-all)"),
	  PARSE_OPT_NOARG, ignore_removal_cb },
	OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
	OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
	OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
开发者ID:Noffica,项目名称:git,代码行数:31,代码来源:add.c


示例9: main

int main(int argc, char **argv)
{
    abrt_init(argv);
    enum {
        OPT_v = 1 << 0,
        OPT_d = 1 << 1,
        OPT_g = 1 << 2,
        OPT_b = 1 << 3,
        OPT_u = 1 << 4,
        OPT_r = 1 << 5,
    };

    const char *bugs = NULL, *release = NULL, *dump_dir_path = ".";
    /* Keep enum above and order of options below in sync! */
    struct options program_options[] = {
        OPT__VERBOSE(&g_verbose),
        OPT__DUMP_DIR(&dump_dir_path),
        OPT_GROUP(""),
        OPT_STRING('b', "bugs", &bugs, "ID1[,ID2,...]" , _("List of bug ids")),
        OPT_STRING('u', "url", &bodhi_url, "URL", _("Specify a bodhi server url")),
        OPT_OPTSTRING('r', "release", &release, "RELEASE", _("Specify a release")),
        OPT_END()
    };

    const char *program_usage_string = _(
        "& [-v] [-r[RELEASE]] (-b ID1[,ID2,...] | PKG-NAME) [PKG-NAME]... \n"
        "\n"
        "Search for updates on bodhi server"
    );

    unsigned opts =  parse_opts(argc, argv, program_options, program_usage_string);

    if (!bugs && !argv[optind])
        show_usage_and_die(program_usage_string, program_options);

    struct strbuf *query = strbuf_new();
    if (bugs)
        query = strbuf_append_strf(query, "bugs=%s&", bugs);

    if (opts & OPT_r)
    {
        if (release)
        {
            query = strbuf_append_strf(query, "release=%s&", release);
        }
        else
        {
            struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
            if (!dd)
                xfunc_die();

            problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
            dd_close(dd);
            if (!problem_data)
                xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */

            char *product, *version;
            map_string_t *osinfo = new_map_string();
            problem_data_get_osinfo(problem_data, osinfo);
            parse_osinfo_for_rhts(osinfo, &product, &version);
            query = strbuf_append_strf(query, "release=f%s&", version);
            free(product);
            free(version);
            free_map_string(osinfo);
        }
    }

    if (argv[optind])
    {
        char *escaped = g_uri_escape_string(argv[optind], NULL, 0);
        query = strbuf_append_strf(query, "package=%s&", escaped);
        free(escaped);
    }

    if (query->buf[query->len - 1] == '&')
        query->buf[query->len - 1] = '\0';

    log(_("Searching for updates"));
    GHashTable *update_hash_tbl = bodhi_query_list(query->buf, release);
    strbuf_free(query);

    if (!update_hash_tbl || !g_hash_table_size(update_hash_tbl))
    {
        log(_("No updates for this package found"));
        /*if (update_hash_tbl) g_hash_table_unref(update_hash_tbl);*/
        return 0;
    }

    GHashTableIter iter;
    char *name;
    struct bodhi *b;
    struct strbuf *q = strbuf_new();
    g_hash_table_iter_init(&iter, update_hash_tbl);
    while (g_hash_table_iter_next(&iter, (void **) &name, (void **) &b))
    {
        char *installed_pkg_nvr = rpm_get_nvr_by_pkg_name(name);
        if (installed_pkg_nvr && rpmvercmp(installed_pkg_nvr, b->nvr) >= 0)
        {
            log_info("Update %s is older or same as local version %s, skipping", b->nvr, installed_pkg_nvr);
            free(installed_pkg_nvr);
//.........这里部分代码省略.........
开发者ID:vrutkovs,项目名称:abrt,代码行数:101,代码来源:bodhi.c


示例10: cmd_name_rev

int cmd_name_rev(int argc, const char **argv, const char *prefix)
{
	struct object_array revs = OBJECT_ARRAY_INIT;
	int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;
	struct name_ref_data data = { 0, 0, NULL };
	struct option opts[] = {
		OPT_BOOL(0, "name-only", &data.name_only, N_("print only names (no SHA-1)")),
		OPT_BOOL(0, "tags", &data.tags_only, N_("only use tags to name the commits")),
		OPT_STRING(0, "refs", &data.ref_filter, N_("pattern"),
				   N_("only use refs matching <pattern>")),
		OPT_GROUP(""),
		OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")),
		OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")),
		OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")),
		OPT_BOOL(0, "always",     &always,
			   N_("show abbreviated commit object as fallback")),
		{
			/* A Hidden OPT_BOOL */
			OPTION_SET_INT, 0, "peel-tag", &peel_tag, NULL,
			N_("dereference tags in the input (internal use)"),
			PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1,
		},
		OPT_END(),
	};

	git_config(git_default_config, NULL);
	argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
	if (all + transform_stdin + !!argc > 1) {
		error("Specify either a list, or --all, not both!");
		usage_with_options(name_rev_usage, opts);
	}
	if (all || transform_stdin)
		cutoff = 0;

	for (; argc; argc--, argv++) {
		unsigned char sha1[20];
		struct object *object;
		struct commit *commit;

		if (get_sha1(*argv, sha1)) {
			fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
					*argv);
			continue;
		}

		commit = NULL;
		object = parse_object(sha1);
		if (object) {
			struct object *peeled = deref_tag(object, *argv, 0);
			if (peeled && peeled->type == OBJ_COMMIT)
				commit = (struct commit *)peeled;
		}

		if (!object) {
			fprintf(stderr, "Could not get object for %s. Skipping.\n",
					*argv);
			continue;
		}

		if (commit) {
			if (cutoff > commit->date)
				cutoff = commit->date;
		}

		if (peel_tag) {
			if (!commit) {
				fprintf(stderr, "Could not get commit for %s. Skipping.\n",
					*argv);
				continue;
			}
			object = (struct object *)commit;
		}
		add_object_array(object, *argv, &revs);
	}

	if (cutoff)
		cutoff = cutoff - CUTOFF_DATE_SLOP;
	for_each_ref(name_ref, &data);

	if (transform_stdin) {
		char buffer[2048];

		while (!feof(stdin)) {
			char *p = fgets(buffer, sizeof(buffer), stdin);
			if (!p)
				break;
			name_rev_line(p, &data);
		}
	} else if (all) {
		int i, max;

		max = get_max_object_index();
		for (i = 0; i < max; i++) {
			struct object *obj = get_indexed_object(i);
			if (!obj || obj->type != OBJ_COMMIT)
				continue;
			show_name(obj, NULL,
				  always, allow_undefined, data.name_only);
		}
	} else {
//.........这里部分代码省略.........
开发者ID:0369,项目名称:git,代码行数:101,代码来源:name-rev.c


示例11: main

/*
 * This application filters the FASTQ reads with the length higher than the value defined
 */
int main(int argc, char *argv[])
{
  Read *Read = CreateRead(65536+GUARD, 65535+GUARD);
  uint32_t sequenceSize = 0, index;
  uint64_t okReads = 0, totalReads = 0;
  int min_read_size = 0;

  char *programName = argv[0];
  struct argparse_option options[] = {
        OPT_HELP(),
        OPT_GROUP("Basic options"),
        OPT_INTEGER('s', "size", &min_read_size, "The maximum read length"),
        OPT_BUFF('<', "input.fastq", "Input FASTQ file format (stdin)"),
        OPT_BUFF('>', "output", "Output read information (stdout)"),
        OPT_END(),
  };
  struct argparse argparse;

  char usage[250] = "\nExample: "; 
  strcat(usage, programName);
  strcat(usage, " < input.fastq > output\n"
    "\nOutput example :\n"
    "<FASTQ non-filtered reads>\n"
    "Total reads    : value\n"
    "Filtered reads : value\n");

  argparse_init(&argparse, options, NULL, programName, 0);
  argparse_describe(&argparse, "\nIt filters the FASTQ reads with the length higher than the value defined. "
    "If present, it will erase the second header (after +).", usage);
  argc = argparse_parse(&argparse, argc, argv);

  if(argc != 0)
    argparse_help_cb(&argparse, options);

  if(min_read_size <= 0 || min_read_size > UINT_MAX)
  {
    fprintf(stderr, "\nERROR: The size value most be a positive unsigned int!\n");
    argparse_help_cb(&argparse, options);
    exit(1);
  }
 
  while(GetRead(stdin, Read))
  {
    sequenceSize = strlen((char *) Read->bases) - 1;
    ++totalReads;

    // Evaluate to discard
    if(sequenceSize > min_read_size) continue;

    // Print the read
    fprintf(stdout, "@");
    for(index = 0 ; index < strlen((char *) Read->header1) ; ++index)
      fprintf(stdout, "%c", Read->header1[index]);
    for(index = 0 ; index < sequenceSize ; ++index)
      fprintf(stdout, "%c", Read->bases[index]);
    fprintf(stdout, "\n+\n");
    for(index = 0 ; index < sequenceSize ; ++index)
      fprintf(stdout, "%c", Read->scores[index]);
    fprintf(stdout, "\n");

    ++okReads;
  }

  fprintf(stderr, "Total reads    : %"PRIu64"\n", totalReads);
  fprintf(stderr, "Filtered reads : %"PRIu64"\n", totalReads-okReads);

  FreeRead(Read);
  return EXIT_SUCCESS;
}
开发者ID:pratas,项目名称:goose,代码行数:72,代码来源:FastqMaximumReadSize.c


示例12: cmd_gidit

int cmd_gidit(int argc, const char **argv, const char *prefix)
{
	int flags = 0;
	int init = 0, verbose = 0, pushobj = 0, updatepl = 0, sign = 0,
		proj_init = 0, polist = 0, store_bundle = 0, get_bundle = 0, pobj_val = 0,
		create_bundle = 0, push = 0, verify_polist = 0, list_missing = 0;

	const char *basepath = NULL;
	const char *keyid = NULL;
	const char *projname = NULL;
	char * url = NULL;
	char *nodekey = NULL;
	char *message = NULL;

	int rc;

	struct option options[] = {
		OPT__VERBOSE(&verbose),
		OPT_GROUP(""),
		OPT_BIT( 0 , "tags", &flags, "include tags", INCLUDE_TAGS),
		OPT_BIT( 0 , "force", &flags, "force", TRANSPORT_PUSH_FORCE),
		OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
		OPT_STRING('u', NULL, &keyid, "key-id",
					"use another key to sign the tag"),
		OPT_BOOLEAN( 0 , "pushobj", &pushobj, "generate push object"),
		OPT_STRING('k',NULL, &nodekey, "nodekey", "key of node"),
		OPT_STRING('m',NULL, &message, "message", "message to send"),
		OPT_STRING('p',NULL, &projname, "project-name", "Project name"),
		OPT_BOOLEAN( 0 , "verify-pobj", &pobj_val, "validate a given pushobject"),
		OPT_BOOLEAN( 0 , "verify-polist", &verify_polist, "verify given polist as all known"),
		OPT_BOOLEAN( 0 , "list-missing", &list_missing, "List sha1's of missing pushobjs"),
		OPT_BOOLEAN( 0 , "push", &push, "Do a push over gidit"),
		OPT_BOOLEAN( 0 , "create-bundle", &create_bundle, 
					"validate a given pushobject"),
		OPT_GROUP(""),
		OPT_BOOLEAN( 0 , "updatepl", &updatepl, "Update push list"),
		OPT_STRING('b', NULL, &basepath, "base-path", "base-path for daemon"),
		OPT_BOOLEAN( 0 , "init", &init, "init gidit directory"),
		OPT_BOOLEAN( 0 , "proj-init", &proj_init, 
					"init user's gidit project directory"),
		OPT_BOOLEAN( 0 , "polist", &polist, "Generate list of push objects"),
		OPT_BOOLEAN( 0 , "store-bundle", &store_bundle, "store a given bundle"),
		OPT_BOOLEAN( 0 , "get-bundle", &get_bundle, "get a bundle"),
		OPT_END()
	};

	git_config(git_gidit_config, NULL);

	argc = parse_options(argc, argv, options, gidit_usage, 0);

	if (push)
		sign = 1;

	if (keyid) {
		sign = 1;
		set_signingkey(keyid);
	} else if (sign) {
		set_default_signingkey();
	}

	if (sign)
		flags |= SIGN;

	if (pushobj)
		return !!gidit_pushobj(stdout, signingkey, flags);
	else if (pobj_val)
		return !!gidit_verify_pushobj(stdin, flags);
	else if (pushobj)
		return !!gidit_pushobj(stdout, signingkey, flags);
	else if (create_bundle)
		return !!gidit_gen_bundle(stdin, flags);
	else if (verify_polist)
		return !!gidit_verify_pushobj_list(stdin);
	else if (list_missing)
		return !!gidit_missing_pushobjs(stdin);
	else if (push) {
		url = (char*)malloc(strlen("gidit://127.0.0.1:9418/") + 
				strlen(projname) + 1 + strlen(signingkey) + 1);
		sprintf(url, "gidit://127.0.0.1:9418/%s:%s", projname, signingkey);
		return !!gidit_push(url, 0, NULL, flags);
	}

	if (!basepath)
		usage_with_options(gidit_usage, options);

	if (base_path_test(basepath))
		return -1;

	if (init)
		rc = gidit_init(basepath);
	else if (proj_init)
		rc = gidit_proj_init_stream(stdin, basepath, flags);
	else if (updatepl)
		rc = gidit_update_pl(stdin, basepath, flags);
	else if (polist)
		rc = gidit_po_list_stream(stdin, basepath, flags);
	else if (store_bundle)
		rc = gidit_store_bundle_stream(stdin, basepath, flags);
	else if (get_bundle)
		rc = gidit_get_bundle(stdin, stdout, basepath, flags);
//.........这里部分代码省略.........
开发者ID:jep56,项目名称:gidit,代码行数:101,代码来源:builtin-gidit.c


示例13: main

/*
 * This application converts a amino acid sequence to a group sequence.
 */
int main(int argc, char *argv[])
{
  int64_t streamSize, index;
  char value;
  BUF *Buffer;

  char *programName = argv[0];
  struct argparse_option options[] = {
        OPT_HELP(),
        OPT_GROUP("Basic options"),
        OPT_BUFF('<', "input.prot", "Input amino acid sequence file (stdin)"),
        OPT_BUFF('>', "output.group", "Output group sequence file (stdout)"),
        OPT_END(),
  };
  struct argparse argparse;

  char usage[500] = "\nExample: "; 
  strcat(usage, programName);
  strcat(usage, " < input.prot > output.group\n");
  strcat(usage, "Table:\n");
  strcat(usage, "Prot\tGroup\n");
  strcat(usage, "R\tP\n");
  strcat(usage, "H\tP  Amino acids with electric charged side chains: POSITIVE\n");
  strcat(usage, "K\tP\n");
  strcat(usage, "-\t-\n");
  strcat(usage, "D\tN\n");
  strcat(usage, "E\tN  Amino acids with electric charged side chains: NEGATIVE\n");
  strcat(usage, "-\t-\n");
  strcat(usage, "S\tU\n");
  strcat(usage, "T\tU\n");
  strcat(usage, "N\tU  Amino acids with electric UNCHARGED side chains\n");
  strcat(usage, "Q\tU\n");
  strcat(usage, "-\t-\n");
  strcat(usage, "C\tS\n");
  strcat(usage, "U\tS\n");
  strcat(usage, "G\tS  Special cases\n");
  strcat(usage, "P\tS\n");
  strcat(usage, "-\t-\n");
  strcat(usage, "A\tH\n");
  strcat(usage, "V\tH\n");
  strcat(usage, "I\tH\n");
  strcat(usage, "L\tH\n");
  strcat(usage, "M\tH  Amino acids with hydrophobic side chains\n");
  strcat(usage, "F\tH\n");
  strcat(usage, "Y\tH\n");
  strcat(usage, "W\tH\n");
  strcat(usage, "-\t-\n");
  strcat(usage, "*\t*  Others\n");
  strcat(usage, "X\tX  Unknown\n");

  argparse_init(&argparse, options, NULL, programName, 0);
  argparse_describe(&argparse, "\nIt converts a amino acid sequence to a group sequence.", usage);
  argc = argparse_parse(&argparse, argc, argv);

  if(argc != 0)
    argparse_help_cb(&argparse, options);

  Buffer = CreateBuffer(BUF_SIZE);
  while((streamSize = fread(Buffer->buf, 1, Buffer->size, stdin)))
  {
    for(index = 0 ; index < streamSize ; ++index)
    {
      value = Buffer->buf[index];
      switch(value)
      {
        case 'R': putchar('P'); break;
        case 'H': putchar('P'); break;
        case 'K': putchar('P'); break;

        case 'D': putchar('N'); break;
        case 'E': putchar('N'); break;

        case 'S': putchar('U'); break;
        case 'T': putchar('U'); break;
        case 'N': putchar('U'); break;
        case 'Q': putchar('U'); break;

        case 'C': putchar('S'); break;
        case 'U': putchar('S'); break;
        case 'G': putchar('S'); break;
        case 'P': putchar('S'); break;

        case 'A': putchar('H'); break;
        case 'V': putchar('H'); break;
        case 'I': putchar('H'); break;
        case 'L': putchar('H'); break;
        case 'M': putchar('H'); break;
        case 'F': putchar('H'); break;
        case 'Y': putchar('H'); break;
        case 'W': putchar('H'); break;

        case '*': putchar('*'); break;
        case 'X': putchar('X'); break;
      }
    }
  }

//.........这里部分代码省略.........
开发者ID:pratas,项目名称:goose,代码行数:101,代码来源:AminoAcidToGroup.c


示例14: parse_archive_args

static int parse_archive_args(int argc, const char **argv,
		const struct archiver **ar, struct archiver_args *args)
{
	const char *format = "tar";
	const char *base = NULL;
	const char *remote = NULL;
	const char *exec = NULL;
	int compression_level = -1;
	int verbose = 0;
	int i;
	int list = 0;
	struct option opts[] = {
		OPT_GROUP(""),
		OPT_STRING(0, "format", &format, "fmt", "archive format"),
		OPT_STRING(0, "prefix", &base, "prefix",
			"prepend prefix to each pathname in the archive"),
		OPT__VERBOSE(&verbose),
		OPT__COMPR('0', &compression_level, "store only", 0),
		OPT__COMPR('1', &compression_level, "compress faster", 1),
		OPT__COMPR_HIDDEN('2', &compression_level, 2),
		OPT__COMPR_HIDDEN('3', &compression_level, 3),
		OPT__COMPR_HIDDEN('4', &compression_level, 4),
		OPT__COMPR_HIDDEN('5', &compression_level, 5),
		OPT__COMPR_HIDDEN('6', &compression_level, 6),
		OPT__COMPR_HIDDEN('7', &compression_level, 7),
		OPT__COMPR_HIDDEN('8', &compression_level, 8),
		OPT__COMPR('9', &compression_level, "compress better", 9),
		OPT_GROUP(""),
		OPT_BOOLEAN('l', "list", &list,
			"list supported archive formats"),
		OPT_GROUP(""),
		OPT_STRING(0, "remote", &remote, "repo",
			"retrieve the archive from remote repository <repo>"),
		OPT_STRING(0, "exec", &exec, "cmd",
			"path to the remote git-upload-archive command"),
		OPT_END()
	};

	argc = parse_options(argc, argv, opts, archive_usage, 0);

	if (remote)
		die("Unexpected option --remote");
	if (exec)
		die("Option --exec can only be used together with --remote");

	if (!base)
		base = "";

	if (list) {
		for (i = 0; i < ARRAY_SIZE(archivers); i++)
			printf("%s\n", archivers[i].name);
		exit(0);
	}

	/* We need at least one parameter -- tree-ish */
	if (argc < 1)
		usage_with_options(archive_usage, opts);
	*ar = lookup_archiver(format);
	if (!*ar)
		die("Unknown archive format '%s'", format);

	args->compression_level = Z_DEFAULT_COMPRESSION;
	if (compression_level != -1) {
		if ((*ar)->flags & USES_ZLIB_COMPRESSION)
			args->compression_level = compression_level;
		else {
			die("Argument not supported for format '%s': -%d",
					format, compression_level);
		}
	}
	args->verbose = verbose;
	args->base = base;
	args->baselen = strlen(base);

	return argc;
}
开发者ID:vmiklos,项目名称:gsoc2008,代码行数:76,代码来源:archive.c


示例15: merge

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OPT_INTEGER函数代码示例发布时间:2022-05-30
下一篇:
C++ OPT_GET函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap