[llvm] [CommandLine] Better report unknown subcommands (PR #74811)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 00:07:57 PST 2023
================
@@ -1687,21 +1705,24 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
}
if (!Handler) {
- if (SinkOpts.empty()) {
+ if (!SinkOpts.empty()) {
+ for (Option *SinkOpt : SinkOpts)
+ SinkOpt->addOccurrence(i, "", StringRef(argv[i]));
+ continue;
+ } else if (i == 1 && !NearestSubCommandString.empty()) {
+ *Errs << ProgramName << ": Unknown subcommand '" << argv[i]
+ << "'. Try: '" << argv[0] << " --help'\n"
+ << ProgramName << ": Did you mean '" << NearestSubCommandString
+ << "'?\n";
----------------
jh7370 wrote:
It would be nice if you could avoid repeating most of the text from below here. I don't necessarily have a concrete sugestion, but perhaps creating a small helper function would be the way forward?
https://github.com/llvm/llvm-project/pull/74811
More information about the llvm-commits
mailing list