Skip to content

Commit

Permalink
[l3nz#153] Multiple + default progress
Browse files Browse the repository at this point in the history
* Replaced flatten with apply concat
* Does not actually work - default values are always included
* Specifying values on cli should replace the defaults
  • Loading branch information
ieugen committed May 29, 2022
1 parent 43205f4 commit 0f90197
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli_matic/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
opts-2)]
(apply
conj positional-opts
(flatten (seq opts-3)))))
(apply concat (seq opts-3)))))

(s/fdef mk-cli-option
:args (s/cat :opts ::S/climatic-option)
Expand Down
25 changes: 24 additions & 1 deletion test/cli_matic/presets_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
[cljc.java-time.zoned-date-time :as zoned-date-time]
[cli-matic.core :refer [parse-command-line]]
[cli-matic.utils-v2 :refer [convert-config-v1->v2]]
[cli-matic.presets :refer [set-help-values set-find-value set-find-didyoumean]]))
[cli-matic.presets :refer [set-help-values set-find-value set-find-didyoumean]]
[cli-matic.utils :as U]
[cli-matic.utils-v2 :as U2]))

(defn cmd_foo [v]
(prn "Foo:" v)
Expand Down Expand Up @@ -240,8 +242,29 @@
{:commandline {:_arguments []
:val "defg"}
:error-text ""
:parse-errors :NONE}))

(testing "multiple strings with default"
(are [i o]
(= (parse-cmds-simpler
i
(mkDummyCfg {:option "val" :as "x" :type :string :multiple true
:default ["a" "b" "c"]})) o)

;
["foo"]
{:commandline {:_arguments []
:val ["a" "b" "c"]}
:error-text ""
:parse-errors :NONE}

["foo" "--val" "abcd" "--val" "defg"]
{:commandline {:_arguments []
:val ["abcd" "defg"]}
:error-text ""
:parse-errors :NONE})))


; :yyyy-mm-dd

(deftest test-dates
Expand Down

0 comments on commit 0f90197

Please sign in to comment.