Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subcommand suggestion #659

Merged
merged 6 commits into from
Jul 24, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,16 @@ main(const int argc, char* argv[]) {
.is_err();
} catch (const structopt::exception& e) {
if (argc > 1) {
int subcommand_index = 1;
wx257osn2 marked this conversation as resolved.
Show resolved Hide resolved
for (; subcommand_index < argc; ++subcommand_index)
if (argv[subcommand_index][0] != '-')
break;
wx257osn2 marked this conversation as resolved.
Show resolved Hide resolved

// try correcting typo
if (const auto sugg =
util::lev_distance::find_similar_str(argv[1], command_list)) {
if (const auto sugg = util::lev_distance::find_similar_str(
argv[subcommand_index], command_list
);
sugg && *sugg != argv[subcommand_index]) {
wx257osn2 marked this conversation as resolved.
Show resolved Hide resolved
err_logger->error(
"{}\n"
" --> Did you mean `{}`?\n\n"
Expand Down