Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,14 @@ int parse(const int argc, char **argv) {
};

auto args = cli::make_args(argc, argv);

// Check if any -h or --help argument was requested, if so insert the help subcommand before any
// arguments, this will ensure the correct help gets printed automatically.
bool help_requested = std::find(args.begin(), args.end(), "--help") != args.end()
|| std::find(args.begin(), args.end(), "-h") != args.end();
if (help_requested) {
args.insert(args.begin(), "help");
}
if (args.empty()) {
usage();
return 0;
Expand Down
Loading