MCPcopy Create free account
hub / github.com/AGWA/git-crypt / main

Function main

git-crypt.cpp:136–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134
135
136int main (int argc, const char** argv)
137try {
138 argv0 = argv[0];
139
140 /*
141 * General initialization
142 */
143
144 init_std_streams();
145 init_crypto();
146
147 /*
148 * Parse command line arguments
149 */
150 int arg_index = 1;
151 while (arg_index < argc && argv[arg_index][0] == '-') {
152 if (std::strcmp(argv[arg_index], "--help") == 0) {
153 print_usage(std::clog);
154 return 0;
155 } else if (std::strcmp(argv[arg_index], "--version") == 0) {
156 print_version(std::clog);
157 return 0;
158 } else if (std::strcmp(argv[arg_index], "--") == 0) {
159 ++arg_index;
160 break;
161 } else {
162 std::clog << argv0 << ": " << argv[arg_index] << ": Unknown option" << std::endl;
163 print_usage(std::clog);
164 return 2;
165 }
166 }
167
168 argc -= arg_index;
169 argv += arg_index;
170
171 if (argc == 0) {
172 print_usage(std::clog);
173 return 2;
174 }
175
176 /*
177 * Pass off to command handler
178 */
179 const char* command = argv[0];
180 --argc;
181 ++argv;
182
183 try {
184 // Public commands:
185 if (std::strcmp(command, "help") == 0) {
186 return help(argc, argv);
187 }
188 if (std::strcmp(command, "version") == 0) {
189 return version(argc, argv);
190 }
191 if (std::strcmp(command, "init") == 0) {
192 return init(argc, argv);
193 }

Callers

nothing calls this directly

Calls 15

init_std_streamsFunction · 0.85
init_cryptoFunction · 0.85
print_usageFunction · 0.85
print_versionFunction · 0.85
helpFunction · 0.85
versionFunction · 0.85
initFunction · 0.85
unlockFunction · 0.85
lockFunction · 0.85
add_gpg_userFunction · 0.85
rm_gpg_userFunction · 0.85
ls_gpg_usersFunction · 0.85

Tested by

no test coverage detected