|
1 |
| -using CodeQLToolkit.Features.CodeQL.Lifecycle.Targets; |
2 |
| -using CodeQLToolkit.Features.CodeQL.Lifecycle; |
3 |
| -using CodeQLToolkit.Features.Test.Lifecycle.Targets; |
4 |
| -using CodeQLToolkit.Features.Test.Lifecycle.Targets.Actions; |
| 1 | +using CodeQLToolkit.Features.CodeQL.Lifecycle; |
5 | 2 | using CodeQLToolkit.Shared.Utils;
|
6 | 3 | using System.CommandLine;
|
7 |
| -using System.Reflection; |
8 | 4 | using CodeQLToolkit.Features.Bundle.Lifecycle.Targets;
|
9 | 5 |
|
10 | 6 | namespace CodeQLToolkit.Features.Bundle.Lifecycle
|
@@ -32,7 +28,18 @@ public override LanguageType[] SupportedLangauges
|
32 | 28 |
|
33 | 29 | public void Register(Command parentCommand)
|
34 | 30 | {
|
35 |
| - //Log<BundleLifecycleFeature>.G().LogInformation("Registering lifecycle submodule."); |
| 31 | + Log<BundleLifecycleFeature>.G().LogInformation("Registering lifecycle submodule."); |
| 32 | + |
| 33 | + var initCommand = new Command("init", "Initialize bundle creation and integration testing features."); |
| 34 | + var overwriteExistingOption = new Option<bool>("--overwrite-existing", () => false, "Overwrite exiting files (if they exist)."); |
| 35 | + var useRunnerOption = new Option<string>("--use-runner", () => "ubuntu-latest", "The runner(s) to use. Should be a comma-seperated list of actions runners."); |
| 36 | + var languageOption = new Option<string>("--language", $"The language to generate automation for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray()); |
| 37 | + |
| 38 | + initCommand.AddOption(overwriteExistingOption); |
| 39 | + initCommand.AddOption(useRunnerOption); |
| 40 | + initCommand.AddOption(languageOption); |
| 41 | + |
| 42 | + parentCommand.Add(initCommand); |
36 | 43 |
|
37 | 44 | var setCommand = new Command("set", "Functions pertaining to setting variables related to custom CodeQL bundles.");
|
38 | 45 | //parentCommand.Add(setCommand);
|
@@ -90,6 +97,27 @@ public void Register(Command parentCommand)
|
90 | 97 | }
|
91 | 98 |
|
92 | 99 |
|
| 100 | + initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, useRunner, language) => |
| 101 | + { |
| 102 | + Log<BundleLifecycleFeature>.G().LogInformation("Executing init command..."); |
| 103 | + |
| 104 | + // |
| 105 | + // dispatch at runtime to the correct automation type |
| 106 | + // |
| 107 | + var featureTarget = AutomationFeatureFinder.FindTargetForAutomationType<BaseLifecycleTarget>(AutomationTypeHelper.AutomationTypeFromString(automationType)); |
| 108 | + |
| 109 | + // setup common params |
| 110 | + featureTarget.FeatureName = FeatureName; |
| 111 | + featureTarget.Base = basePath; |
| 112 | + featureTarget.OverwriteExisting = overwriteExisting; |
| 113 | + featureTarget.UseRunner = useRunner; |
| 114 | + featureTarget.Language = language; |
| 115 | + featureTarget.DevMode = devMode; |
| 116 | + featureTarget.Run(); |
| 117 | + |
| 118 | + }, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, useRunnerOption, languageOption); |
| 119 | + |
| 120 | + |
93 | 121 | }
|
94 | 122 |
|
95 | 123 | public int Run()
|
|
0 commit comments