From 2e7b3b12f5a7562a67f31ae2b61a440fb83819c5 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 21 Dec 2023 18:47:56 +0100 Subject: [PATCH] faaaaaail --- src/babashka/cli.cljc | 2 +- test/babashka/cli_test.cljc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/babashka/cli.cljc b/src/babashka/cli.cljc index e606505..6aa1bb1 100644 --- a/src/babashka/cli.cljc +++ b/src/babashka/cli.cljc @@ -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] diff --git a/test/babashka/cli_test.cljc b/test/babashka/cli_test.cljc index 0e73ecc..747af94 100644 --- a/test/babashka/cli_test.cljc +++ b/test/babashka/cli_test.cljc @@ -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}} @@ -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