commandlineparser / commandlineparser/commandline
Question - can f# matching handle verbs?
- 主要语言
- C#
- 星标
- 4.8k
- 派生
- 478
- PR 合并指标
- 30 天内没有已合并 PR
描述
Sorry for question as issue, googled a bit and had no luck.
Is the F# matching support meant to work with verbs? I'm trying
```fs
[]
type UploadOptions = {
[] FileName: string;
[] RootUrl: string;
}
[]
type OtherOptions = {
[] Opt: string;
}
let getOpts argv : CLIOptions =
let result = CommandLine.Parser.Default.ParseArguments(argv)
match result with
| :? Parsed as p -> p.Value // <-- compile error here
| :? Parsed as p -> p.Value
| :? NotParsed as e ->
let errs = e.Errors |> Seq.map string |> Seq.toList
failwith <| String.Join("\n", errs)
| _ -> failwith "bang"
```
But this fails to compile:
```
Type constraint mismatch. The type
'Parsed'
is not compatible with type
'ParserResult'
```
I don't have a good understanding of how C# types map to F# sorry, so apologies if I'm missing something obvious.
EDIT: Never mind, found the readme. Consider this a feature request to not need to double match against `obj`. :)
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 README 中关于 F# 支持的指导以及 issue 中展示的 ParserResult、Parsed 和 NotParsed 类型开始。确定如何向 F# 调用方公开特定于 verb 的结果;当调用方可以对已解析命令的结果进行匹配,而无需针对 obj 进行两次匹配时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100