commandlineparser / commandlineparser/commandline

Question - can f# matching handle verbs?

オープン
#774 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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`. :)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。