`args->opts` does not handle positional args after `--`
まだ誰も着手していません。
- #242 @codebeige による — マージされずにクローズ
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 領域
- cli
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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"]}}
- 主要言語
- Clojure
- スター
- 305
- フォーク
- 24
- 平均マージ
- 1分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
babashka/cli のほかの issue
-
Usage help: "Inherited options" heading might be confusing in some contexts対応中かも @Sinkleberg が 28 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nextjournal/clerk#830 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
penpot/penpot#13540 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100