diff --git a/common/command_line.cpp b/common/command_line.cpp index 59a893731787..0c043c15c406 100644 --- a/common/command_line.cpp +++ b/common/command_line.cpp @@ -1039,7 +1039,8 @@ auto Parser::ParseShortOptionSeq(llvm::StringRef unparsed_arg) auto* arg_entry = (c < short_option_table_.size()) ? short_option_table_[c] : nullptr; if (!arg_entry) { - return Error(llvm::formatv("unknown short option `{0}`", c)); + return Error( + llvm::formatv("unknown short option `-{0}`", static_cast(c))); } // Mark this argument as parsed. arg_entry->setInt(true); diff --git a/common/command_line_test.cpp b/common/command_line_test.cpp index 2a45cb6817a5..1157aa8b9dc9 100644 --- a/common/command_line_test.cpp +++ b/common/command_line_test.cpp @@ -188,6 +188,10 @@ TEST(ArgParserTest, ShortArgs) { EXPECT_THAT(integer_option, Eq(123)); TestRawOstream os; + + EXPECT_THAT(parse({"-v"}, os), IsError(StrEq("unknown short option `-v`"))); + EXPECT_THAT(parse({"-xvx"}, os), IsError(StrEq("unknown short option `-v`"))); + EXPECT_THAT( parse({"-xzf"}, os), IsError(StrEq("option `-z` (short for `--option2`) requires a value to "