https://github.com/frodehus/quicli
A lightweight framework for creating CLI applications with the primary focus of being compatible with AOT and trimming. This is to generate small and fast self-contained executables.
https://github.com/frodehus/quicli
cli dotnet framework
Last synced: 12 months ago
JSON representation
A lightweight framework for creating CLI applications with the primary focus of being compatible with AOT and trimming. This is to generate small and fast self-contained executables.
- Host: GitHub
- URL: https://github.com/frodehus/quicli
- Owner: FrodeHus
- License: mit
- Created: 2024-05-26T20:23:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-07T06:24:32.000Z (12 months ago)
- Last Synced: 2025-04-07T07:26:13.394Z (12 months ago)
- Topics: cli, dotnet, framework
- Language: C#
- Homepage:
- Size: 236 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# QuiCLI
[](https://github.com/FrodeHus/QuiCLI/actions/workflows/dotnet.yml)
[](https://github.com/FrodeHus/QuiCLI/actions/workflows/nuget.yml)
[](https://github.com/FrodeHus/QuiCLI/actions/workflows/github-code-scanning/codeql)
A lightweight framework for creating CLI applications with the primary focus of being compatible with AOT and trimming. This is to generate small and fast self-contained executables.
Because of the restrictions imposed by trimming and AOT, the framework is designed to be as simple as possible. This means that it does not support certain features that are common in other CLI frameworks that requires extensive reflection.
The framework is built on top of Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.Configuration, which means that it is possible to use the same configuration and dependency injection system as in ASP.NET Core.
As an example of an application that uses QuiCLI, see [SecurityCenterCLI](https://github.com/FrodeHus/SecurityCenterCLI) and [RFDump](https://github.com/FrodeHus/RFDump).
## Features
- Dependency injection
- Command line argument parsing
- Command line argument help generation
- Command line argument type conversion
- Nested command groups
## Quick start
_Note:_ The framework is still in early development, and the API is subject to change.
The only supported returns types for asynchronous commands are `Task`, `Task` and `Task` due to reflection restrictions. For synchronous commands, everything is supported.
Registration of commands is explicit by design to make the code as efficient and clear as possible without heavy reflection usage.
`dotnet add package QuiCLI`
```csharp
using Microsoft.Extensions.DependencyInjection;
using QuiCLI;
using SampleApp;
var builder = QuicApp.CreateBuilder();
builder.Configure(config => config.CustomBanner = () => "Welcome to SampleApp!");
builder.Services.AddTransient();
builder.Commands.Add()
.WithCommand("hello", x => x.Hello)
.WithCommand("bye", x => x.Bye);
var informalGroup = builder.Commands.WithGroup("informal");
informalGroup
.Add()
.WithCommand("sup", x => x.Sup)
.WithCommand("hey", x => x.Hey);
informalGroup
.Add()
.WithCommand("cya", x => x.Cya)
.WithCommand("later", x => x.Later);
var app = builder.Build();
app.Run();
```
```csharp
using QuiCLI.Command;
namespace SampleApp;
internal class HelloCommand(GreeterService greeterService)
{
private readonly GreeterService _greeterService = greeterService;
public string Hello(
[Parameter(help: "Which name to greet")] string name,
[Parameter(help: "Define which year should be displayed")] int year = 2024)
{
return $"Hello, {name}! Welcome to {year}!";
}
public string Bye(string name)
{
return _greeterService.SayGoodbye(name);
}
}
```
```cmd
myapp hello --name "World"
```
```cmd
sampleapp.exe --help
Welcome to SampleApp!
Usage:
[arguments]
Commands:
hello
bye
Nested Commands:
informal
Global Arguments:
--help : Show help information
--output : Output format
```