Skip to content

Commit

Permalink
READme
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiandymel authored Dec 29, 2018
1 parent 74e46d5 commit d0a5272
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CLI-Argument-Parser
Library to parse command line arguments - attributes based approach. C# and .netCore

## How to use it?

Create a class to hold desired configuration settings, mark with attributes:

```csharp
public class ProgramConfig
{
[Option]
[OptionAlias("--help")]
[OptionAlias("-h")]
public bool ShowHelp { get; set; }

[Option]
[OptionAlias("--version")]
[OptionAlias("-v")]
public bool ShowVersionDetails { get; set; }

[Option]
[OptionAlias("--age-of-client")]
[OptionAlias("-a")]
public int Age { get; set; }
}
```


Parse it:
```csharp
class Program
{
static void Main(string[] args)
{
var parser = new AttributeParser();
var configuration = parser.Parse<ProgramConfig>(args);
}
}
```

Use it in application
```csharp
if (configuration.ShowHelp)
{
Console.WriteLine("HEEELP");
}
```

0 comments on commit d0a5272

Please sign in to comment.