`args->opts` does not handle positional args after `--`
Nessuno ha ancora preso questa issue.
- #242 di @codebeige — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Ambito
- cli
Direzione di ricerca
Start at parse-args in babashka/cli.cljc:908 and trace how -- separates positional arguments from the remaining args; compare that path with the existing :args->opts processing. Check the CLI tests for :args->opts and :restrict-args, then add coverage showing that post--- values are validated, coerced, and included in the option collection.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
version
0.12.92
platform
macos/arm64
problem
Positional arguments following -- are not handled by :args->opts and therefore stay unprocessed in :args without being added to the option's collection.
repro
(babashka.cli/parse-args ["foo" "bar" "--" "baz"]
{:args->opts [:positional-args]
:spec [[:positional-args {:coerce []}]]})
; => {:args ["baz"], :opts {:positional-args ["foo" "bar"]}}
With :restrict-args enabled, the following error is expected given the above behavior, but I think it is still be worth mentioning:
% bb -e '(babashka.cli/parse-args ["foo" "bar" "--" "baz"] {:args->opts [:positional-args] :restrict-args true :spec [[:positional-args {:coerce []}]]})'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Unexpected argument: baz
Data: {:spec [[:positional-args {:coerce []}]], :type :org.babashka/cli, :cause :restrict-args, :msg "Unexpected argument: baz", :value "baz", :opts {:positional-args ["foo" "bar"]}}
Location: NO_SOURCE_PATH:1:1
----- Context ------------------------------------------------------------------
1: (babashka.cli/parse-args ["foo" "bar" "--" "baz"] {:args->opts [:positional-args] :restrict-args true :spec [[:positional-args {:coerce []}]]})
^--- Unexpected argument: baz
----- Stack trace --------------------------------------------------------------
babashka.cli/->error-fn/fn--24916 - <built-in>
babashka.cli/->error-fn/fn--24918 - <built-in>
babashka.cli/validate-opts - <built-in>
babashka.cli/parse-opts - <built-in>
babashka.cli/parse-args - babashka/cli.cljc:908:1
user - NO_SOURCE_PATH:1:1
expected behavior
Positional arguments following -- undergo the same processing (i.e. validation, coercion) as the ones before it, and everything is folded into the option's collection.
(babashka.cli/parse-args ["foo" "bar" "--" "baz"]
{:args->opts [:positional-args]
:spec [[:positional-args {:coerce []}]]})
; => {:opts {:positional-args ["foo" "bar" "baz"]}}
- Lingua principale
- Clojure
- Stelle
- 305
- Fork
- 24
- Merge medio
- 1m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di babashka/cli
-
Usage help: "Inherited options" heading might be confusing in some contextsForse già presa @Sinkleberg l’ha presa 28 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Missing some GitHub ReleasesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tutte le issue di babashka/cli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
nextjournal/clerk#830 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
penpot/penpot#13540 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100