mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Use return in place of exit() in README and samples
Only those places in the README where an error is explicitly found in the main function have been updated. Other uses of exit are left untouched as there is not enough context to know if return will work in that location. Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
parent
0ae3c7d919
commit
9377e0d3b2
10
README.md
10
README.md
@ -99,7 +99,7 @@ int main(int argc, char *argv[]) {
|
||||
catch (const std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto input = program.get<int>("square");
|
||||
@ -781,7 +781,7 @@ int main(int argc, char *argv[]) {
|
||||
catch (const std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Use arguments
|
||||
@ -908,7 +908,7 @@ int main(int argc, char *argv[]) {
|
||||
catch (const std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("+f")) {
|
||||
@ -956,7 +956,7 @@ int main(int argc, char *argv[]) {
|
||||
catch (const std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("--foo")) {
|
||||
@ -1104,7 +1104,7 @@ int main(int argc, char *argv[]) {
|
||||
catch (const std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("--foo")) {
|
||||
|
@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto a = program.get<bool>("-a"); // true
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("--foo")) {
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("+f")) {
|
||||
|
@ -12,7 +12,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto color = program.get<std::string>("--color"); // "orange"
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto colors = program.get<std::vector<std::string>>(
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto files = program.get<std::vector<std::string>>(
|
||||
|
@ -17,7 +17,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program.is_used("integer")) {
|
||||
|
@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (program["--verbose"] == true) {
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int input = program.get<int>("square");
|
||||
|
@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Output written to " << program.get("-o") << "\n";
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (const std::runtime_error &err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
std::cerr << program;
|
||||
std::exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Use arguments
|
||||
|
Loading…
Reference in New Issue
Block a user