Q: Is there a way to fail if unknown flags/arguments are passed?
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 領域
- cli
調査の方向性
例に示されている cli/dispatch* エントリーポイントから始め、未定義の引数がディスパッチされた結果のエントリになるまでの流れを追跡します。未知のフラグに対する strict-mode の期待される動作を定義し、次にタイプミスのケースのカバレッジを追加して、有効なフラグが引き続き機能することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Hi,
If the user passes an undefined flag is there a way to fail the cli/dispatch?
I assume that is a design choice to accept flags which have not been defined, but in some cases might be risky if fore example someone has a typo in a flag.
For example look at the following (contrived) example:
;; this command deletes the given argument
(def delete identity)
(cli/dispatch*
{:command #'delete
:flags ["-v, --verbose" "Increases verbosity"
"--dry-run" "Simulate but do not action"
"--input FILE" "Specify the input file/folder"
"--env=<dev|prod|test>" {:doc "Select an environment" :default "prod"}]}
;; typo in --dryrun (the correct should be --dry-run)
["--input" "all-my-data" "--dryrun"])
;; => {:lambdaisland.cli/sources
;; {:env "--env=<dev|prod|test> (default value)",
;; :input "--input command line flag"},
;; :env "prod",
;; :lambdaisland.cli/argv [],
;; :input "all-my-data",
;; :dryrun 1}
In this example the user might thing that he provided the --dryrun argument, the dispatcher will just dispatch as a new flag ignoring the fact that it was an unintentional mistake and because delete doesn't see the flag :dry-run true it will perform the actual delete.
Is there a way to add a :strict-mode true and fail on undefined flags?
- 主要言語
- Clojure
- スター
- 56
- フォーク
- 1
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
.Team/Metabot Priority:P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
needs triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100