dotnet / dotnet/command-line-api
F# app model
- Lingua principale
- C#
- Stelle
- 3.7k
- Fork
- 428
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
It would be nice to have F# parser like this Haskell library https://github.com/pcapriotti/optparse-applicative . I like that you can just pattern match the result. And it looks cool.
In F# it might look like the following when use (almost real code). Using notion from https://github.com/fsprojects/FSharpPlus
```f#
type Sample =
{ hello : string
quiet : bool
enthusiasm : int }
let currySample (hello : string) (quiet : bool) (enthusiasm : int) =
{ hello = hello
quiet = quiet
enthusiasm = enthusiasm }
let parser =
currySample
Option(Aliases [ "--hello"; "-h" ]
+ HelpDetail "description"
+ Argument ExactlyOne "TARGET")
<*> Option(Aliases [ "-q" ]
+ HelpDetail "description"
+ Argument Zero)
<*> Option(Aliases [ "--enthusiasm" ]
+ HelpDetail "description"
+ Argument ExactlyOne "INT")
let result : Sample = runParser parser "--hello Bob -q --enthusiasm 3"
```
To add in subcommand, Sample need to be a union and it should use alternative to combine parser https://github.com/pcapriotti/optparse-applicative#alternative
Problems:
1. Is there a genetic way to curry Record type? Or we may need to use Tuple.
2. How to fit Argument? Just by position could be fine. During config, the name of the Record field is not used.
...
...
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia confrontando l’API del parser F# di esempio con il pattern matching e le sezioni alternative di optparse-applicative a cui si fa riferimento, quindi esamina le nozioni di FSharpPlus citate nell’issue. Per considerarlo completato, sarebbe necessario un design concreto per record o tuple, la gestione di Argument e i subcommand prima di poter definire l’ambito dell’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- fsharp, haskell
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100