Skip to content

Commit

Permalink
faaaaaail
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 21, 2023
1 parent 6036868 commit 2e7b3b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/babashka/cli.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@

(defn- table->tree [table]
(reduce (fn [tree {:as cfg :keys [cmds]}]
(assoc-in tree cmds (dissoc cfg :cmds)))
(assoc-in tree (interleave (repeat :cmd) cmds) (dissoc cfg :cmds)))
{} table))

(defn- deep-merge [a b]
Expand Down
14 changes: 12 additions & 2 deletions test/babashka/cli_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
(is (submap? {:dispatch ["foo" "bar" "baz"] , :opts {:baz true :quux :xyzzy}, :args nil}
(cli/dispatch table ["foo" "bar" "--baz" "baz" "--quux" "xyzzy"]))))

(d/deflet
#_#_(d/deflet
(def tree {:spec {:global {:coerce :boolean}}
"foo" {"bar" {:fn identity
"baz" {:fn identity}}
Expand Down Expand Up @@ -347,7 +347,17 @@
:args ["bar" "arg1"]}
(cli/dispatch-tree
tree
["--foo" "dude1" "foo" "--foo" "dude2" "bar" "--foo" "dude3" "bar" "arg1"]))))))
["--foo" "dude1" "foo" "--foo" "dude2" "bar" "--foo" "dude3" "bar" "arg1"])))

(def tree {:spec spec
:cmd "foo"
:sub {:cmd "bar"
:sub {:cmd "bar"
:sub {:cmd "baz"
:fn identity
:spec spec}}
:spec spec
:fn identity}}))))

(deftest no-keyword-opts-test (is (= {:query [:a :b :c]}
(cli/parse-opts
Expand Down

0 comments on commit 2e7b3b1

Please sign in to comment.