commandlineparser / commandlineparser/commandline

Option without value should throw an error.

Open
#861 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

If I have a string option and it is called without a value, no error is thrown. This is what I would expect.

```csharp
using CommandLine;

namespace cli
{
public class Program
{
static void Main(string[] args)
{
CommandLine.Parser.Default.ParseArguments(args)
.WithParsed(options => RunOptions(options))
.WithNotParsed(error => ErrorAndExit(error));
}

static void RunOptions(Options options)
{

}

static void ErrorAndExit(IEnumerable error)
{ }
}

public class Options
{
[Option("value", Required = false, HelpText = "A value.")]
public string Value { get; set; }
}
}
```
If i call this command line i get no error.

```bash
cli --value # should throw an error
cli --value blah # ok, this is what i want
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.