Skip to content

Commit

Permalink
Allow .NET CDP code generator to run silently
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Nov 12, 2020
1 parent cc5cf1b commit cc70098
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions dotnet/private/generate_devtools.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def _generate_devtools_impl(ctx):
args.add_all("-b", [ctx.attr.browser_protocol.files.to_list()[0]])
args.add_all("-j", [ctx.attr.js_protocol.files.to_list()[0]])
args.add_all("-t", [ctx.attr.template.files.to_list()[0]])
args.add("-q")
args.add_all("-o", [outdir.path])

ctx.actions.run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public CommandLineOptions()
HelpText = "Forces the Chrome Protocol Definition to be downloaded from source even if it already exists.")]
public bool ForceDownload { get; set; }

[Option(
'q',
"quiet",
Default = false,
HelpText = "Suppresses console output.")]
public bool Quiet { get; set; }

[Option(
"force",
Default = false,
Expand Down
30 changes: 25 additions & 5 deletions third_party/dotnet/devtools/src/generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,37 @@ static int Main(string[] args)
.BuildServiceProvider();

//Get the protocol Data.
Console.WriteLine("Loading protocol definition...");
if (!cliArguments.Quiet)
{
Console.WriteLine("Loading protocol definition...");
}

var protocolDefinitionData = GetProtocolDefinitionData(cliArguments);

var protocolDefinition = protocolDefinitionData.ToObject<ProtocolDefinition.ProtocolDefinition>(new JsonSerializer() { MetadataPropertyHandling = MetadataPropertyHandling.Ignore });

//Begin the code generation process.
Console.WriteLine("Generating protocol definition code files...");
if (!cliArguments.Quiet)
{
Console.WriteLine("Generating protocol definition code files...");
}

var protocolGenerator = serviceProvider.GetRequiredService<ICodeGenerator<ProtocolDefinition.ProtocolDefinition>>();
var codeFiles = protocolGenerator.GenerateCode(protocolDefinition, null);

//Delete the output folder if force is specified and it exists...
Console.WriteLine("Writing generated code files to {0}...", cliArguments.OutputPath);
if (!cliArguments.Quiet)
{
Console.WriteLine("Writing generated code files to {0}...", cliArguments.OutputPath);
}

if (Directory.Exists(cliArguments.OutputPath) && cliArguments.ForceOverwrite)
{
Console.WriteLine("Generating protocol definition project...");
if (!cliArguments.Quiet)
{
Console.WriteLine("Generating protocol definition project...");
}

Directory.Delete(cliArguments.OutputPath, true);
}

Expand Down Expand Up @@ -84,7 +100,11 @@ static int Main(string[] args)
}

//Completed.
Console.WriteLine("All done!");
if (!cliArguments.Quiet)
{
Console.WriteLine("All done!");
}

return 0;
}

Expand Down

0 comments on commit cc70098

Please sign in to comment.