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

Function export_key

commands.cpp:1372–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1370 out << "When FILENAME is -, export to standard out." << std::endl;
1371}
1372int export_key (int argc, const char** argv)
1373{
1374 // TODO: provide options to export only certain key versions
1375 const char* key_name = 0;
1376 Options_list options;
1377 options.push_back(Option_def("-k", &key_name));
1378 options.push_back(Option_def("--key-name", &key_name));
1379
1380 int argi = parse_options(options, argc, argv);
1381
1382 if (argc - argi != 1) {
1383 std::clog << "Error: no filename specified" << std::endl;
1384 help_export_key(std::clog);
1385 return 2;
1386 }
1387
1388 Key_file key_file;
1389 load_key(key_file, key_name);
1390
1391 const char* out_file_name = argv[argi];
1392
1393 if (std::strcmp(out_file_name, "-") == 0) {
1394 key_file.store(std::cout);
1395 } else {
1396 if (!key_file.store_to_file(out_file_name)) {
1397 std::clog << "Error: " << out_file_name << ": unable to write key file" << std::endl;
1398 return 1;
1399 }
1400 }
1401
1402 return 0;
1403}
1404
1405void help_keygen (std::ostream& out)
1406{

Callers 1

mainFunction · 0.85

Calls 6

Option_defClass · 0.85
parse_optionsFunction · 0.85
help_export_keyFunction · 0.85
load_keyFunction · 0.85
storeMethod · 0.80
store_to_fileMethod · 0.80

Tested by

no test coverage detected