mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:10:12 +01:00
Refactor command line errors to mirror diagnostic style (#4568)
This changes to an `Error` return to let the driver do the "error: " prefix, except for one case with `help` that needs more work to change (I'm not planning on picking up that TODO). It also changes capitalization, backtick use, and a few minor punctuation things to try to better match the diagnostic style. This also adds `Error` matchers so that the changes to command line testing are clearer.
This commit is contained in:
@@ -54,9 +54,8 @@ auto Run(llvm::ArrayRef<llvm::StringRef> args) -> bool {
|
||||
int lines = 10'000;
|
||||
SourceGen::Language language;
|
||||
|
||||
CommandLine::ParseResult parsed_args = CommandLine::Parse(
|
||||
args, llvm::outs(), llvm::errs(), Info,
|
||||
[&](CommandLine::CommandBuilder& b) {
|
||||
auto parse_result = CommandLine::Parse(
|
||||
args, llvm::outs(), Info, [&](CommandLine::CommandBuilder& b) {
|
||||
b.AddStringOption(OutputArgInfo,
|
||||
[&](auto& arg_b) { arg_b.Set(&output_filename); });
|
||||
b.AddIntegerOption(LinesArgInfo,
|
||||
@@ -74,9 +73,10 @@ auto Run(llvm::ArrayRef<llvm::StringRef> args) -> bool {
|
||||
// No-op action as there is only one operation for this command.
|
||||
b.Do([] {});
|
||||
});
|
||||
if (parsed_args == CommandLine::ParseResult::Error) {
|
||||
if (!parse_result.ok()) {
|
||||
llvm::errs() << "error: " << *parse_result << "\n";
|
||||
return false;
|
||||
} else if (parsed_args == CommandLine::ParseResult::MetaSuccess) {
|
||||
} else if (*parse_result == CommandLine::ParseResult::MetaSuccess) {
|
||||
// Fully handled by the CLI library.
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user