commandlineparser / commandlineparser/commandline

Option without value should throw an error.

Ouverte
#861 3 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C#
Étoiles
4.8k
Forks
478
Métriques de merge des PR
Aucune PR mergée en 30 j

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
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.