Skip to content

Commit 8cc600d

Browse files
committed
Add CLI framework and update JetBrains.Annotations references
- Introduced `CreativeCoders.Cli.Core` and `CreativeCoders.Cli.Hosting` libraries for building CLI applications. - Added new interfaces (`ICliCommand`, `ICliHost`) and features such as command scanning, host building, and results handling. - Created `CliHostSampleApp` as a usage example with sample commands. - Developed unit tests for CLI command scanning, host building, and execution. - Updated JetBrains.Annotations package to `2025.2.4` across all projects.
1 parent 53944e5 commit 8cc600d

33 files changed

Lines changed: 453 additions & 11 deletions

File tree

‎Core.sln‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "junie", "junie", "{6CAB0BC8
237237
EndProject
238238
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessUtilsSampleApp", "samples\ProcessUtilsSampleApp\ProcessUtilsSampleApp.csproj", "{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39}"
239239
EndProject
240+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cli", "Cli", "{CDCF2469-1668-4EB0-A73F-692115CF6776}"
241+
EndProject
242+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Cli.Core", "source\Cli\CreativeCoders.Cli.Core\CreativeCoders.Cli.Core.csproj", "{4E628A1A-953A-4274-B4EF-F33E943A650D}"
243+
EndProject
244+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Cli.Hosting", "source\Cli\CreativeCoders.Cli.Hosting\CreativeCoders.Cli.Hosting.csproj", "{ED92EBC6-C297-46AE-998B-155A26442AA5}"
245+
EndProject
246+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliHostSampleApp", "samples\CliHostSampleApp\CliHostSampleApp.csproj", "{CA248700-A9E0-433E-98FE-4E1C6844811F}"
247+
EndProject
248+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Cli.Tests", "tests\CreativeCoders.Cli.Tests\CreativeCoders.Cli.Tests.csproj", "{FF482B6D-D459-413E-82E0-9175C44DA8BA}"
249+
EndProject
240250
Global
241251
GlobalSection(SolutionConfigurationPlatforms) = preSolution
242252
Debug|Any CPU = Debug|Any CPU
@@ -545,6 +555,22 @@ Global
545555
{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39}.Debug|Any CPU.Build.0 = Debug|Any CPU
546556
{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39}.Release|Any CPU.ActiveCfg = Release|Any CPU
547557
{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39}.Release|Any CPU.Build.0 = Release|Any CPU
558+
{4E628A1A-953A-4274-B4EF-F33E943A650D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
559+
{4E628A1A-953A-4274-B4EF-F33E943A650D}.Debug|Any CPU.Build.0 = Debug|Any CPU
560+
{4E628A1A-953A-4274-B4EF-F33E943A650D}.Release|Any CPU.ActiveCfg = Release|Any CPU
561+
{4E628A1A-953A-4274-B4EF-F33E943A650D}.Release|Any CPU.Build.0 = Release|Any CPU
562+
{ED92EBC6-C297-46AE-998B-155A26442AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
563+
{ED92EBC6-C297-46AE-998B-155A26442AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
564+
{ED92EBC6-C297-46AE-998B-155A26442AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
565+
{ED92EBC6-C297-46AE-998B-155A26442AA5}.Release|Any CPU.Build.0 = Release|Any CPU
566+
{CA248700-A9E0-433E-98FE-4E1C6844811F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
567+
{CA248700-A9E0-433E-98FE-4E1C6844811F}.Debug|Any CPU.Build.0 = Debug|Any CPU
568+
{CA248700-A9E0-433E-98FE-4E1C6844811F}.Release|Any CPU.ActiveCfg = Release|Any CPU
569+
{CA248700-A9E0-433E-98FE-4E1C6844811F}.Release|Any CPU.Build.0 = Release|Any CPU
570+
{FF482B6D-D459-413E-82E0-9175C44DA8BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
571+
{FF482B6D-D459-413E-82E0-9175C44DA8BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
572+
{FF482B6D-D459-413E-82E0-9175C44DA8BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
573+
{FF482B6D-D459-413E-82E0-9175C44DA8BA}.Release|Any CPU.Build.0 = Release|Any CPU
548574
EndGlobalSection
549575
GlobalSection(SolutionProperties) = preSolution
550576
HideSolutionNode = FALSE
@@ -648,6 +674,11 @@ Global
648674
{7EA4E4D9-BC5F-401A-A143-99816D46ABC2} = {FCD8D558-7F1F-4D2E-B2EA-DE412BCEE1F7}
649675
{6CAB0BC8-210F-4AFF-902F-91F3BFF64CC8} = {FCD8D558-7F1F-4D2E-B2EA-DE412BCEE1F7}
650676
{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39} = {72E179CA-7AE6-412A-856D-7BD13838E8E3}
677+
{CDCF2469-1668-4EB0-A73F-692115CF6776} = {2A7105AA-05B6-469A-93F5-719723A4D90D}
678+
{4E628A1A-953A-4274-B4EF-F33E943A650D} = {CDCF2469-1668-4EB0-A73F-692115CF6776}
679+
{ED92EBC6-C297-46AE-998B-155A26442AA5} = {CDCF2469-1668-4EB0-A73F-692115CF6776}
680+
{CA248700-A9E0-433E-98FE-4E1C6844811F} = {72E179CA-7AE6-412A-856D-7BD13838E8E3}
681+
{FF482B6D-D459-413E-82E0-9175C44DA8BA} = {5A3FFD14-2258-4007-AC77-BAFB3B3EB26F}
651682
EndGlobalSection
652683
GlobalSection(ExtensibilityGlobals) = postSolution
653684
SolutionGuid = {EE24476B-9A4C-4146-B982-3461FAF8B3B0}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\..\source\Cli\CreativeCoders.Cli.Core\CreativeCoders.Cli.Core.csproj"/>
12+
<ProjectReference Include="..\..\source\Cli\CreativeCoders.Cli.Hosting\CreativeCoders.Cli.Hosting.csproj"/>
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using CreativeCoders.Cli.Core;
2+
3+
namespace CliHostSampleApp;
4+
5+
public class DemoCliCommand : ICliCommand<ICliCommandContext>
6+
{
7+
public DemoCliCommand() { }
8+
9+
public async Task<CommandResult> ExecuteAsync(ICliCommandContext context)
10+
{
11+
Console.WriteLine("Hello World!");
12+
13+
return new CommandResult();
14+
}
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using CreativeCoders.Cli.Hosting;
2+
3+
namespace CliHostSampleApp;
4+
5+
public static class Program
6+
{
7+
static async Task Main(string[] args)
8+
{
9+
await CreateCliHost().RunAsync(args).ConfigureAwait(false);
10+
}
11+
12+
private static ICliHost CreateCliHost()
13+
{
14+
return CliHostBuilder.Create()
15+
.Build();
16+
}
17+
}

‎source/AspNetCore/CreativeCoders.AspNetCore.TokenAuthApi.Jwt/CreativeCoders.AspNetCore.TokenAuthApi.Jwt.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2"/>
10+
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4"/>
1111
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0"/>
1212
</ItemGroup>
1313

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace CreativeCoders.Cli.Core;
2+
3+
[AttributeUsage(AttributeTargets.Class)]
4+
public class CliCommandAttribute : Attribute
5+
{
6+
public string[] Commands { get; }
7+
8+
public CliCommandAttribute(string[] commands)
9+
{
10+
Commands = commands;
11+
}
12+
13+
public string Description { get; set; } = string.Empty;
14+
15+
public string[][] AdditionalCommands { get; set; }
16+
17+
public bool IsDefaultCommand { get; set; }
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace CreativeCoders.Cli.Core;
2+
3+
public class CommandResult
4+
{
5+
public int ExitCode { get; set; }
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace CreativeCoders.Cli.Core;
2+
3+
public interface ICliCommand<TOptions>
4+
where TOptions : class
5+
{
6+
Task<CommandResult> ExecuteAsync(TOptions options);
7+
}
8+
9+
public interface ICliCommand
10+
{
11+
Task<CommandResult> ExecuteAsync();
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace CreativeCoders.Cli.Core;
2+
3+
public interface ICliCommandContext { }
4+
5+
public class CliCommandContext : ICliCommandContext { }

0 commit comments

Comments
 (0)