https://github.com/ackara/nshellit
A .netstandard command-line parser and powershell module generator.
https://github.com/ackara/nshellit
commandline console netstandard parser powershell wrapper
Last synced: about 1 year ago
JSON representation
A .netstandard command-line parser and powershell module generator.
- Host: GitHub
- URL: https://github.com/ackara/nshellit
- Owner: Ackara
- License: mit
- Created: 2018-03-01T19:45:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-23T15:05:13.000Z (about 8 years ago)
- Last Synced: 2025-01-25T08:09:34.044Z (about 1 year ago)
- Topics: commandline, console, netstandard, parser, powershell, wrapper
- Language: C#
- Size: 168 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# NShellit
[](https://www.nuget.org/packages/Acklann.NShellit/)
[](https://www.nuget.org/packages/Acklann.NShellit/)
---
## What is NShellit?
NShellit is a command-line parser inspired by *powershell*. Powershell has one of the best argument convention around, so why not incorporate it into console applications.
### Where can I get?
NShellit is available at [nuget.org](https://www.nuget.org/packages/Acklann.NShellit).
### How it works?
First you will need to create a simple class that will store the options for your command, and decorate them with the following Attributes.
```csharp
class CoolCommand : ICommand
{
[Required, Parameter]
public string SomeString { get; set; }
[Parameter]
public int SomeNumber { get; set; }
[Parameter("s", "enabale")]
public bool SomeSwitch { get; set; }
int Execute() { ... }
}
```
Next in your `Program.cs` file add the following.
```csharp
var parser = Acklann.NShellit.Parser.MapResults(args, typeof(CoolCommand));
/// OR EVEN BETTER
/// var parser = Acklann.NShellit.Parser.MapResults(args, allCommandTypes);
if (parser.HasResult)
{
var command = parser.GetResult();
return command.Execute();
}
else return parser.PrintUsage();
```