commandlineparser / commandlineparser/commandline

Question - can f# matching handle verbs?

Aberta
#774 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
C#
Estrelas
4.8k
Forks
478
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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`. :)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Start with the README's F# support guidance and the ParserResult, Parsed, and NotParsed types shown in the issue. Determine how verb-specific results are exposed to F# callers; done means callers can match the parsed command result without double matching against obj.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp
Domínio
cli
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.