Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bilal-fazlani/commanddotnet
A modern framework for building modern CLI apps
https://github.com/bilal-fazlani/commanddotnet
argument-parser command-line console-application csharp dotnet-core
Last synced: 3 months ago
JSON representation
A modern framework for building modern CLI apps
- Host: GitHub
- URL: https://github.com/bilal-fazlani/commanddotnet
- Owner: bilal-fazlani
- License: mit
- Created: 2017-10-24T21:05:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T14:00:21.000Z (9 months ago)
- Last Synced: 2024-10-14T02:16:53.114Z (3 months ago)
- Topics: argument-parser, command-line, console-application, csharp, dotnet-core
- Language: C#
- Homepage: https://commanddotnet.bilal-fazlani.com
- Size: 4.79 MB
- Stars: 571
- Watchers: 11
- Forks: 29
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-csharp - CommandDotNet - Model your console app using C# in a composable manner. Define commands with methods. Define subcommands with properties or nested classes. Extensible parsing and command execution. (CLI)
- awesome-dotnet-cn - CommandDotNet - 使用C#以可组合的方式模块化你的控制台应用。用方法定义命令,用属性或嵌套类定义定义子命令。解析与命令的执行是可扩展的。 (CLI)
- awesome-dotnet-core - commanddotnet - Model your command line application interface in a class. (Frameworks, Libraries and Tools / Misc)
- awesome-cli-frameworks - CommandDotnet
- awesome-dotnet-core - commanddotnet - 在类中为您的命令行应用程序接口建模。 (框架, 库和工具 / 大杂烩)
- jimsghstars - bilal-fazlani/commanddotnet - A modern framework for building modern CLI apps (C# #)
- awsome-dotnet - CommandDotNet - Model your console app using C# in a composable manner. Define commands with methods. Define subcommands with properties or nested classes. Extensible parsing and command execution. (CLI)
- fucking-awesome-dotnet-core - commanddotnet - Model your command line application interface in a class. (Frameworks, Libraries and Tools / Misc)
- awesome-dotnet - CommandDotNet - Model your console app using C# in a composable manner. Define commands with methods. Define subcommands with properties or nested classes. Extensible parsing and command execution. (CLI)
- awesome-dotnet-core - commanddotnet - Model your command line application interface in a class. (Frameworks, Libraries and Tools / Misc)
README
![Nuget](https://img.shields.io/nuget/v/commanddotnet?style=for-the-badge)
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/CommandDotNet.svg?style=for-the-badge)](https://www.nuget.org/packages/CommandDotNet)
[![NuGet](https://img.shields.io/nuget/dt/CommandDotNet.svg?style=for-the-badge)](https://www.nuget.org/packages/CommandDotNet)
[![GitHub](https://img.shields.io/github/license/bilal-fazlani/commanddotnet?style=for-the-badge)](https://github.com/bilal-fazlani/commanddotnet/blob/master/LICENSE)[![GitHub last commit](https://img.shields.io/github/last-commit/bilal-fazlani/CommandDotNet.svg?style=for-the-badge)]()
![Netlify](https://img.shields.io/netlify/ce6331f7-bbfb-4a8a-ba7c-705b2902c4f5?label=Netlify%20Build&style=for-the-badge)
[![Build](https://img.shields.io/github/workflow/status/bilal-fazlani/commanddotnet/Test/master?style=for-the-badge)](https://github.com/bilal-fazlani/commanddotnet/actions/workflows/test.yml)[![Gitter](https://img.shields.io/gitter/room/badges/shields.svg?style=for-the-badge)](https://gitter.im/CommandDotNet/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Discord](https://img.shields.io/discord/678568687556493322?label=Discord%20Chat&style=for-the-badge)](https://discord.gg/QFxKSeG)# CommandDotNet
### A modern framework for building modern CLI apps
Out of the box support for commands, sub-commands, validations, dependency injection,
piping and streaming, enums & custom types, typo suggestions, prompting, passwords, response files and much more!
See the [features page](https://commanddotnet.bilal-fazlani.com/features).Favors [POSIX conventions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html)
Includes [test tools](TestTools/overview.md) used by the framework to test all features of the framework.
Modify and extend the functionality of the framework through configuration and middleware.
### Documentation 👉 https://commanddotnet.bilal-fazlani.com
## Project Status
This project is stable. Lack of new features are a result of the maturity of the library, not an indication of the liveliness of this project.
We are available to fix bugs and answer questions and remain fairly responsive. There are PRs and issues in the backlog for new features that are currently low priority for the maintainers. We will accept PRs. If you haven't discussed them with us first and the change is significant, please consider the submission the beginning of a design discussion.## Support
For bugs, [create an issue](https://github.com/bilal-fazlani/commanddotnet/issues/new)
For questions and feature requests, start [a discussion](https://github.com/bilal-fazlani/commanddotnet/discussions)
For a quick walkthrough of features, see our [Getting Started guides](https://commanddotnet.bilal-fazlani.com/gettingstarted/getting-started-0/)
Here's a starter:
### Example
Begin by creating the commands:
```cs
public class Program
{
// this is the entry point of your application
static int Main(string[] args)
{
// AppRunner where T is the class defining your commands
// You can use Program or create commands in another class
return new AppRunner().Run(args);
}// Add command with two positional arguments
public void Add(int x, int y) => Console.WriteLine(x + y);// Subtract command with two positional arguments
public void Subtract(int x, int y) => Console.WriteLine(x - y);
}
```
snippet source | anchorThat's it. You now have an application with two commands. Let's see about how we can call it from command line.
Assuming our application's name is `calculator.dll`, let's run this app from command line using dotnet.
First we'll check out the auto-generated help.
```bash
$ dotnet calculator.dll --help
Usage: dotnet calculator.dll [command]Commands:
Add
SubtractUse "dotnet calculator.dll [command] --help" for more information about a command.
```
snippet source | anchorFrom the root we can see the available commands. Instead of `--help` we could have used `-h` or `-?`.
We'll use `-h` to get help for the _Add_ command.
```bash
$ dotnet calculator.dll Add -h
Usage: dotnet calculator.dll AddArguments:
x
y
```
snippet source | anchorLet's try it out by adding two numbers
```bash
$ dotnet calculator.dll Add 40 20
60
```
snippet source | anchorCommandDotNet will validate if the arguments can be converted to the correct type.
```bash
$ dotnet calculator.dll Add a 20
'a' is not a valid Number
```
snippet source | anchorCheck out the docs for more examples
See our [Getting Started guides](https://commanddotnet.bilal-fazlani.com/gettingstarted/getting-started-0/) to see how to improve the help documentation, test the application and utilize the many other features of CommandDotNet.
## Credits 🎉
Special thanks to [Drew Burlingame](https://github.com/drewburlingame) for continuous support and contributions