Skip to content

Commit 2994f52

Browse files
committed
checkpoint for jeongsoo
1 parent 82c47fd commit 2994f52

File tree

10 files changed

+192
-3
lines changed

10 files changed

+192
-3
lines changed

CodeQLToolkit.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeQLToolkit.Features.Code
3939
EndProject
4040
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeQLToolkit.Features.CodeQL.Lifecycle", "src\CodeQLToolkit.Features.CodeQL.Lifecycle\CodeQLToolkit.Features.CodeQL.Lifecycle.csproj", "{FCC3A25B-29D4-4626-816A-B4BD62D14992}"
4141
EndProject
42+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeQLToolkit.Features.Pack", "CodeQLToolkit.Features.Pack", "{DB21251D-9281-44FA-99CD-BFEE2571C340}"
43+
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQLToolkit.Features.Pack", "src\CodeQLToolkit.Features.Pack\CodeQLToolkit.Features.Pack.csproj", "{48CF8986-5E37-43DB-8045-5F64C25076E7}"
45+
EndProject
4246
Global
4347
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4448
Debug|Any CPU = Debug|Any CPU
@@ -73,6 +77,10 @@ Global
7377
{FCC3A25B-29D4-4626-816A-B4BD62D14992}.Debug|Any CPU.Build.0 = Debug|Any CPU
7478
{FCC3A25B-29D4-4626-816A-B4BD62D14992}.Release|Any CPU.ActiveCfg = Release|Any CPU
7579
{FCC3A25B-29D4-4626-816A-B4BD62D14992}.Release|Any CPU.Build.0 = Release|Any CPU
80+
{48CF8986-5E37-43DB-8045-5F64C25076E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81+
{48CF8986-5E37-43DB-8045-5F64C25076E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
82+
{48CF8986-5E37-43DB-8045-5F64C25076E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
83+
{48CF8986-5E37-43DB-8045-5F64C25076E7}.Release|Any CPU.Build.0 = Release|Any CPU
7684
EndGlobalSection
7785
GlobalSection(SolutionProperties) = preSolution
7886
HideSolutionNode = FALSE
@@ -88,6 +96,8 @@ Global
8896
{47F5F5EF-C1F9-4932-878C-2D00C17411F4} = {667B480C-D805-4A9C-AC1F-D9FCCF3DB57C}
8997
{860F6AB3-40C2-41F9-A1CE-D708B9347CAD} = {47F5F5EF-C1F9-4932-878C-2D00C17411F4}
9098
{FCC3A25B-29D4-4626-816A-B4BD62D14992} = {47F5F5EF-C1F9-4932-878C-2D00C17411F4}
99+
{DB21251D-9281-44FA-99CD-BFEE2571C340} = {667B480C-D805-4A9C-AC1F-D9FCCF3DB57C}
100+
{48CF8986-5E37-43DB-8045-5F64C25076E7} = {DB21251D-9281-44FA-99CD-BFEE2571C340}
91101
EndGlobalSection
92102
GlobalSection(ExtensibilityGlobals) = postSolution
93103
SolutionGuid = {BF8F3B81-F4DC-4608-A41C-F00F3E5A05CA}

src/CodeQLToolkit.Core/CodeQLToolkit.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
<ItemGroup>
2525
<ProjectReference Include="..\CodeQLToolkit.Features.CodeQL\CodeQLToolkit.Features.CodeQL.csproj" />
26+
<ProjectReference Include="..\CodeQLToolkit.Features.Pack\CodeQLToolkit.Features.Pack.csproj" />
2627
<ProjectReference Include="..\CodeQLToolkit.Features.Query\CodeQLToolkit.Features.Query.csproj" />
2728
<ProjectReference Include="..\CodeQLToolkit.Features.Test\CodeQLToolkit.Features.Test.csproj" />
2829
<ProjectReference Include="..\CodeQLToolkit.Shared\CodeQLToolkit.Shared.csproj" />

src/CodeQLToolkit.Core/Main.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using CodeQLToolkit.Shared.Utils;
99
using CodeQLToolkit.Features.CodeQL;
1010
using CodeQLToolkit.Features.Test;
11+
using CodeQLToolkit.Features.Pack;
1112

1213
namespace CodeQLDevelopmentLifecycleToolkit.Core
1314
{
@@ -42,7 +43,9 @@ public static async Task<int> Main(string[] args)
4243
CodeQLFeatureMain.Instance.Register(rootCommand);
4344
// Register the `Test` feature
4445
TestFeatureMain.Instance.Register(rootCommand);
45-
46+
// Register the `Pack` feature
47+
PackFeatureMain.Instance.Register(rootCommand);
48+
4649
await rootCommand.InvokeAsync(args);
4750

4851
return 0;

src/CodeQLToolkit.Core/ver.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.16
1+
0.0.17
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\CodeQLToolkit.Shared\CodeQLToolkit.Shared.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<Folder Include="Lifecycle\" />
15+
<Folder Include="Templates\" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using CodeQLToolkit.Features.Pack.Commands.Targets;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.CommandLine;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace CodeQLToolkit.Features.Pack.Commands
10+
{
11+
public class PackCommandFeature : FeatureBase, IToolkitCommandFeature
12+
{
13+
public void Register(Command parentCommand)
14+
{
15+
Log<PackCommandFeature>.G().LogInformation("Registering command submodule.");
16+
17+
var runCommand = new Command("run", "Functions pertaining to running pack-related commands.");
18+
parentCommand.Add(runCommand);
19+
20+
// a command that installs query packs
21+
var sayHello = new Command("hello-jeongsoo", "Says hello!");
22+
var howManyTimesHello = new Option<int>("--times", "how many times to say it") { IsRequired = true };
23+
sayHello.Add(howManyTimesHello);
24+
25+
var sayGoodbye = new Command("goodbye-jeongsoo", "Says goodbye!");
26+
27+
var howManyTimes = new Option<int>("--times", "how many times to say it") { IsRequired = true };
28+
sayGoodbye.Add(howManyTimes);
29+
30+
31+
runCommand.Add(sayHello);
32+
runCommand.Add(sayGoodbye);
33+
34+
sayHello.SetHandler((basePath, times) => {
35+
36+
new HelloJeongsooCommandTarget() {
37+
Base = basePath,
38+
Times = times
39+
40+
}.Run();
41+
42+
}, Globals.BasePathOption, howManyTimesHello);
43+
44+
sayGoodbye.SetHandler((basePath, times) => {
45+
46+
Console.WriteLine($"Saying goodbye {times} number of times");
47+
48+
for (int i = 0; i < times; i++)
49+
{
50+
Console.WriteLine("Goodbye!");
51+
}
52+
53+
54+
}, Globals.BasePathOption, howManyTimes);
55+
56+
}
57+
58+
public int Run()
59+
{
60+
throw new NotImplementedException();
61+
}
62+
}
63+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using CodeQLToolkit.Shared.Utils;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace CodeQLToolkit.Features.Pack.Commands.Targets
9+
{
10+
public class HelloJeongsooCommandTarget : CommandTarget
11+
{
12+
13+
public int Times { get; set; }
14+
15+
16+
public override void Run()
17+
{
18+
for(int i = 0; i < Times; i++) {
19+
Console.WriteLine($"Hello! My Base Target is: {Base}");
20+
}
21+
22+
23+
var c = new QLTConfig()
24+
{
25+
Base = Base
26+
};
27+
28+
if (!File.Exists(c.CodeQLConfigFilePath))
29+
{
30+
ProcessUtils.DieWithError($"Cannot read values from missing file {c.CodeQLConfigFilePath}");
31+
}
32+
33+
var config = c.FromFile();
34+
35+
36+
Console.WriteLine($"---------current settings---------");
37+
Console.WriteLine($"CodeQL CLI Version: {config.CodeQLCLI}");
38+
Console.WriteLine($"CodeQL Standard Library Version: {config.CodeQLStandardLibrary}");
39+
Console.WriteLine($"CodeQL CLI Bundle Version: {config.CodeQLCLIBundle}");
40+
Console.WriteLine($"----------------------------------");
41+
Console.WriteLine("(hint: use `qlt codeql set` to modify these values.)");
42+
43+
}
44+
}
45+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
global using CodeQLToolkit.Shared.Target;
2+
global using CodeQLToolkit.Shared.Logging;
3+
global using Microsoft.Extensions.Logging;
4+
global using CodeQLToolkit.Shared.Feature;
5+
global using CodeQLToolkit.Shared.Options;
6+
global using CodeQLToolkit.Shared.Types;
7+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using CodeQLToolkit.Features.Pack.Commands;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.CommandLine;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace CodeQLToolkit.Features.Pack
10+
{
11+
public class PackFeatureMain : IToolkitFeature
12+
{
13+
14+
readonly static PackFeatureMain instance;
15+
readonly PackCommandFeature commandFeature;
16+
17+
static PackFeatureMain()
18+
{
19+
instance = new PackFeatureMain();
20+
}
21+
22+
private PackFeatureMain()
23+
{
24+
commandFeature = new PackCommandFeature();
25+
}
26+
public static PackFeatureMain Instance { get { return instance; } }
27+
28+
public void Register(Command parentCommand)
29+
{
30+
var packCommand = new Command("pack", "Features CodeQL pack management and publication.");
31+
parentCommand.Add(packCommand);
32+
33+
Log<PackFeatureMain>.G().LogInformation("Registering scaffolding submodule.");
34+
commandFeature.Register(packCommand);
35+
}
36+
37+
public int Run()
38+
{
39+
throw new NotImplementedException();
40+
}
41+
}
42+
}

src/CodeQLToolkit.Shared/Utils/QLTConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class QLTConfig
1212
public string CodeQLCLI { get; set; }
1313
public string CodeQLStandardLibrary { get; set; }
1414
public string CodeQLCLIBundle { get; set; }
15-
15+
1616
public string CodeQLStandardLibraryIdent {
1717
get {
1818
return CodeQLStandardLibrary.Replace("/", "_");

0 commit comments

Comments
 (0)