Options shown in Global section can include unreachable alternatives.

Aperta
#461 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
cli

Direzione di ricerca

Start by examining the topLevelParser expression in the issue, especially how hsubparser combines subcommands with launchCommand as a fallback. Read the parser-combinator implementation and existing parser tests to determine whether an empty command can be represented separately from global options. Done means launch options are shown only for the no-subcommand path and are rejected or absent for commands such as run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello 👋🏼

The CLI for Unison has one very common use-case (launching the unison shell) and several other 'utility' commands. The way we have things set up right now is as follows:

  • ucm without any subcommand runs the 'launch' behaviour
  • ucm run defers to the run subcommand.

The way we've implemented this is by using our launch option parser as a fallback for our subcommand parser:

topLevelParser =
  hsubparser subcommands <|> launchCommand

Meaning that if the user doesn't provide a command, we interpret it as a 'launch'.

The issue is that currently optparse-applicative interprets all of the options of launch as global options, even though all of those options will fail if passed to the run subcommand for example.

Is there any way to indicate options as being only relevant if no subcommand is provided, rather than showing them as global?

Effectively I want the empty command to just be treated as another subcommand.

This may not be the most common setup, but if you can think of a way to make this work I'd love to hear it 😄

Thank you for maintaining such an awesome tool, it saves us a lot of time :D

Lingua principale
Haskell
Stelle
957
Fork
124
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pcapriotti/optparse-applicative

Tutte le issue di pcapriotti/optparse-applicative

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.