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

Function keygen

commands.cpp:1412–1440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1410 out << "When FILENAME is -, write to standard out." << std::endl;
1411}
1412int keygen (int argc, const char** argv)
1413{
1414 if (argc != 1) {
1415 std::clog << "Error: no filename specified" << std::endl;
1416 help_keygen(std::clog);
1417 return 2;
1418 }
1419
1420 const char* key_file_name = argv[0];
1421
1422 if (std::strcmp(key_file_name, "-") != 0 && access(key_file_name, F_OK) == 0) {
1423 std::clog << key_file_name << ": File already exists" << std::endl;
1424 return 1;
1425 }
1426
1427 std::clog << "Generating key..." << std::endl;
1428 Key_file key_file;
1429 key_file.generate();
1430
1431 if (std::strcmp(key_file_name, "-") == 0) {
1432 key_file.store(std::cout);
1433 } else {
1434 if (!key_file.store_to_file(key_file_name)) {
1435 std::clog << "Error: " << key_file_name << ": unable to write key file" << std::endl;
1436 return 1;
1437 }
1438 }
1439 return 0;
1440}
1441
1442void help_migrate_key (std::ostream& out)
1443{

Callers 1

mainFunction · 0.85

Calls 4

help_keygenFunction · 0.85
generateMethod · 0.80
storeMethod · 0.80
store_to_fileMethod · 0.80

Tested by

no test coverage detected