commandlineparser / commandlineparser/commandline

Option without value should throw an error.

Abierto
#861 3 comentarios 3 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C#
Estrellas
4.8k
Forks
478
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.