File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ For breaking changes, check [here](#breaking-changes).
7
7
## Unreleased
8
8
9
9
- Fix [ #102 ] ( https://github.com/babashka/cli/issues/102 ) : ` format-table ` correctly pads cells containing ANSI escape codes
10
+ - Fix [ #106 ] ( https://github.com/babashka/cli/issues/106 ) : Multiple options before subcommand conflict with subcommand
10
11
11
12
## v0.8.60 (2024-07-23)
12
13
Original file line number Diff line number Diff line change 418
418
(not= arg " true" )
419
419
(not= arg " false" ))
420
420
(and (= added current-opt)
421
- (not collect-fn)))]
421
+ (or
422
+ (not collect-fn)
423
+ (contains? (::dispatch-tree-ignored-args opts) (first args)))))]
422
424
(if the-end?
423
425
(let [{new-args :args
424
426
a->o :args->opts }
535
537
(fn [widths row]
536
538
(map max (map str-width row) widths)) (repeat 0 ) rows)
537
539
pad-row (fn [row]
538
- (map ( fn [width cell] ( pad width cell)) widths row))]
540
+ (map pad widths row))]
539
541
(map pad-row rows)))
540
542
541
543
(defn format-table [{:keys [rows indent] :or {indent 2 }}]
Original file line number Diff line number Diff line change 587
587
:spec {:x {:coerce :boolean }}}]
588
588
[" foo" ]
589
589
{:restrict true }))))
590
+
591
+ (deftest issue-106-test
592
+ (d/deflet
593
+ (def global-spec {:config {:desc " Config edn file to use"
594
+ :coerce []}
595
+ :verbose {:coerce :boolean }})
596
+ (def dns-spec {})
597
+ (def dns-get-spec {})
598
+ (def table
599
+ [{:cmds [] :fn identity :spec global-spec}
600
+ {:cmds [" dns" ] :fn identity :spec dns-spec}
601
+ {:cmds [" dns" " get" ] :fn identity :spec dns-get-spec}])
602
+ (is (submap?
603
+ {:dispatch [" dns" ], :opts {:config [" config-dev.edn" " other.edn" ]}, :args nil }
604
+ (cli/dispatch table [" --config" " config-dev.edn" " --config" " other.edn" " dns" ])))
605
+ (is (submap?
606
+ {:dispatch [" dns" " get" ],
607
+ :opts {:config [" config-dev.edn" " other.edn" ]},
608
+ :args nil }
609
+ (cli/dispatch table [" --config" " config-dev.edn" " --config" " other.edn" " dns" " get" ])))
610
+ (is (submap?
611
+ {:dispatch [" dns" " get" ],
612
+ :opts {:config [" config-dev.edn" " other.edn" ], :verbose true },
613
+ :args nil }
614
+ (cli/dispatch table [" --config" " config-dev.edn" " --verbose" " --config" " other.edn" " dns" " get" ])))
615
+ (is (submap?
616
+ {:dispatch [" dns" " get" ],
617
+ :opts {:config [" config-dev.edn" " other.edn" ]},
618
+ :args nil }
619
+ (cli/dispatch table [" --config" " config-dev.edn" " --config=other.edn" " dns" " get" ]))))
620
+ )
You can’t perform that action at this time.
0 commit comments