Refactor subcommand addition for sharing. (#4474)

Trying to standardize the setup a little more.
This commit is contained in:
Jon Ross-Perkins
2024-11-04 22:42:57 +00:00
committed by GitHub
parent ea0b0b4b48
commit 26e58b4587
12 changed files with 110 additions and 87 deletions
+17 -15
View File
@@ -42,21 +42,6 @@ auto operator<<(llvm::raw_ostream& out, CompileOptions::Phase phase)
return out;
}
constexpr CommandLine::CommandInfo CompileOptions::Info = {
.name = "compile",
.help = R"""(
Compile Carbon source code.
This subcommand runs the Carbon compiler over input source code, checking it for
errors and producing the requested output.
Error messages are written to the standard error stream.
Different phases of the compiler can be selected to run, and intermediate state
can be written to standard output as these phases progress.
)""",
};
auto CompileOptions::Build(CommandLine::CommandBuilder& b) -> void {
b.AddStringPositionalArg(
{
@@ -284,6 +269,23 @@ Emit DWARF debug information.
});
}
static constexpr CommandLine::CommandInfo SubcommandInfo = {
.name = "compile",
.help = R"""(
Compile Carbon source code.
This subcommand runs the Carbon compiler over input source code, checking it for
errors and producing the requested output.
Error messages are written to the standard error stream.
Different phases of the compiler can be selected to run, and intermediate state
can be written to standard output as these phases progress.
)""",
};
CompileSubcommand::CompileSubcommand() : DriverSubcommand(SubcommandInfo) {}
auto CompileSubcommand::ValidateOptions(DriverEnv& driver_env) const -> bool {
using Phase = CompileOptions::Phase;
switch (options_.phase) {