commandlineparser / commandlineparser/commandline
Option without value should throw an error.
- Lingua principale
- C#
- Stelle
- 4.8k
- Fork
- 478
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Riproduci il comportamento con CommandLine.Parser.Default.ParseArguments usando la classe Options e gli esempi di --value. Segui il punto di ingresso dell'analisi dei valori delle opzioni e trova i test esistenti del parser; il lavoro è completato quando --value invoca WithNotParsed in caso di valore string mancante, mentre --value blah viene ancora analizzato correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100