Skip to content

Commit

Permalink
Catch unknown arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Mar 8, 2025
1 parent 5cb6f6b commit e8843ef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ bool has_flag(int argc, char** argv, char const* str) {
}

int main(int argc, char** argv) {
if (argc < 2) {
if (argc < 2 || has_flag(argc - 1, argv + 1, "--help") ||
has_flag(argc - 1, argv + 1, "-h")) {
printf(
"Usage:\n"
" pkg load | -l [clone dependencies]\n"
Expand All @@ -40,6 +41,8 @@ int main(int argc, char** argv) {
has_flag(argc - 1, argv + 1, "-r"));
} else if (mode == "status" || mode == "-s") {
print_status(fs::path{"."}, fs::path("deps"));
} else {
fmt::print("Unknown mode {}. See pkg --help for usage.", mode);
}
} catch (std::exception const& e) {
std::cerr << "error: " << e.what() << "\n";
Expand Down

0 comments on commit e8843ef

Please sign in to comment.