summaryrefslogtreecommitdiffstats
path: root/src/cli/common.h
blob: 3aed8ad8a42ec2bee1c91d80920d4c6627396ed4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (C) the libgit2 contributors. All rights reserved.
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */

#ifndef CLI_common_h__
#define CLI_common_h__

#define PROGRAM_NAME "git2"

#include "git2_util.h"

#include "error.h"
#include "opt.h"
#include "opt_usage.h"

/*
 * Common command arguments.
 */

#define CLI_COMMON_OPT_HELP \
	CLI_OPT_TYPE_SWITCH, "help",       0, &show_help, 1, \
	CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING
#define CLI_COMMON_OPT_CONFIG \
	CLI_OPT_TYPE_VALUE,   NULL,       'c', NULL,      0, \
	CLI_OPT_USAGE_HIDDEN
#define CLI_COMMON_OPT_CONFIG_ENV \
	CLI_OPT_TYPE_VALUE,  "config-env", 0,  NULL,      0, \
	CLI_OPT_USAGE_HIDDEN

#define CLI_COMMON_OPT \
	{ CLI_COMMON_OPT_HELP }, \
	{ CLI_COMMON_OPT_CONFIG }, \
	{ CLI_COMMON_OPT_CONFIG_ENV }

typedef struct {
	char **args;
	int args_len;
} cli_repository_open_options;

extern int cli_repository_open(
	git_repository **out,
	cli_repository_open_options *opts);

/*
 * Common command arguments.
 */

#define CLI_COMMON_OPT_HELP \
	CLI_OPT_TYPE_SWITCH, "help",       0, &show_help, 1, \
	CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING
#define CLI_COMMON_OPT_CONFIG \
	CLI_OPT_TYPE_VALUE,   NULL,       'c', NULL,      0, \
	CLI_OPT_USAGE_HIDDEN
#define CLI_COMMON_OPT_CONFIG_ENV \
	CLI_OPT_TYPE_VALUE,  "config-env", 0,  NULL,      0, \
	CLI_OPT_USAGE_HIDDEN

#define CLI_COMMON_OPT \
	{ CLI_COMMON_OPT_HELP }, \
	{ CLI_COMMON_OPT_CONFIG }, \
	{ CLI_COMMON_OPT_CONFIG_ENV }

#endif /* CLI_common_h__ */