mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:14:43 +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:
@@ -84,19 +84,21 @@ auto Options::Build(CommandLine::CommandBuilder& b) -> void {
|
||||
|
||||
auto Driver::RunCommand(llvm::ArrayRef<llvm::StringRef> args) -> DriverResult {
|
||||
if (driver_env_.installation->error()) {
|
||||
llvm::errs() << "error: " << *driver_env_.installation->error() << "\n";
|
||||
driver_env_.error_stream << "error: " << *driver_env_.installation->error()
|
||||
<< "\n";
|
||||
return {.success = false};
|
||||
}
|
||||
|
||||
Options options;
|
||||
|
||||
CommandLine::ParseResult result = CommandLine::Parse(
|
||||
args, driver_env_.output_stream, driver_env_.error_stream, Options::Info,
|
||||
ErrorOr<CommandLine::ParseResult> result = CommandLine::Parse(
|
||||
args, driver_env_.output_stream, Options::Info,
|
||||
[&](CommandLine::CommandBuilder& b) { options.Build(b); });
|
||||
|
||||
if (result == CommandLine::ParseResult::Error) {
|
||||
if (!result.ok()) {
|
||||
driver_env_.error_stream << "error: " << result.error() << "\n";
|
||||
return {.success = false};
|
||||
} else if (result == CommandLine::ParseResult::MetaSuccess) {
|
||||
} else if (*result == CommandLine::ParseResult::MetaSuccess) {
|
||||
return {.success = true};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user