commandlineparser / commandlineparser/commandline
Cannot parse "1"
- 主要语言
- C#
- 星标
- 4.8k
- 派生
- 478
- PR 合并指标
- 30 天内没有已合并 PR
描述
E.g. "--KEEP_ALIVE_OPTION=1".
This treats by the parser as no value:
_Option 'keep_alive_option" has no value.
Required option 'keep_alive_option' is missing._
```
public class KeepAliveOptions
{
[Option(Required = true)]
public string KEEP_ALIVE_OPTION { get; set; }
[Option(Required = true)]
public string LOGIN_URL { get; set; }
[Option(Required = true)]
public string ADVISOR_PASSWORD { get; set; }
[Option(Required = true)]
public string COMPANY_NUMBER { get; set; }
[Option(Required = true)]
public string OUT_DIR { get; set; }
[Option(Required = true)]
public string UserID { get; set; }
[Option(Required = true)]
public string Password { get; set; }
}
```
```
public ParserResult Parse(string[] args) where T : IScriptOptions
{
Parser parser = new(s =>
{
s.CaseSensitive = false;
s.IgnoreUnknownArguments = true;
s.HelpWriter = Parser.Default.Settings.HelpWriter;
});
var scriptOptions = new List();
for (int i = 0; i < args.Length; i++)
{
string option = $"--{args[i].TrimStart('/')}";
scriptOptions.Add(option);
}
return parser.ParseArguments(scriptOptions);
}
```
```
var result = Parse(args)
.WithParsed(keepAliveOptions => options = keepAliveOptions)
```
Tried to change KEEP_ALIVE_OPTION type to int, it doesn't change anything
Fiddle: https://dotnetfiddle.net/vbujQc
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。