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
+9 -7
View File
@@ -14,13 +14,6 @@
namespace Carbon {
constexpr CommandLine::CommandInfo FormatOptions::Info = {
.name = "format",
.help = R"""(
Format Carbon source code.
)""",
};
auto FormatOptions::Build(CommandLine::CommandBuilder& b) -> void {
b.AddStringPositionalArg(
{
@@ -49,6 +42,15 @@ Not valid when multiple files are passed for formatting.
[&](auto& arg_b) { arg_b.Set(&output_filename); });
}
static constexpr CommandLine::CommandInfo SubcommandInfo = {
.name = "format",
.help = R"""(
Format Carbon source code.
)""",
};
FormatSubcommand::FormatSubcommand() : DriverSubcommand(SubcommandInfo) {}
auto FormatSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
DriverResult result = {.success = true};
if (options_.input_filenames.size() > 1 &&