From 54159daf14a9ddad9f5575239470a71dea6a74ac Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 27 Jul 2026 14:49:16 +0200 Subject: [PATCH] Help: two-space divider in the Commands section --- CHANGELOG.md | 4 ++++ src/babashka/cli.cljc | 4 ++-- test/babashka/cli_test.cljc | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8270bbf..8f72ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ For breaking changes, check [here](#breaking-changes). [Babashka CLI](https://github.com/babashka/cli): turn Clojure functions into CLIs! +## Unreleased + +- Help: separate command names and docs with two spaces, like the `Options:` and `Arguments:` sections + ## 0.12.84 - zsh completion: offer a command's options without typing a dash first, by opting the registered program names out of zsh's `prefix-needed` style diff --git a/src/babashka/cli.cljc b/src/babashka/cli.cljc index 2768237..ccd6d15 100644 --- a/src/babashka/cli.cljc +++ b/src/babashka/cli.cljc @@ -1244,7 +1244,7 @@ (conj desc) (seq cmds) - (conj (str "Commands:\n" (format-table {:rows cmds :indent 2}))) + (conj (str "Commands:\n" (format-table {:rows cmds :indent 2 :divider " "}))) (seq arg-rows) (conj (str "Arguments:\n" (format-table {:rows arg-rows :indent 2 :divider " "}))) @@ -2010,7 +2010,7 @@ $env.config.completions.external.completer = {|spans| (str/join "\n" (concat [message ""] (when (seq cmds) - [(str "Commands:\n" (format-table {:rows cmds :indent 2})) ""]) + [(str "Commands:\n" (format-table {:rows cmds :indent 2 :divider " "})) ""]) [hint]))))] (cond (or (= :no-match cause) (= :input-exhausted cause)) diff --git a/test/babashka/cli_test.cljc b/test/babashka/cli_test.cljc index 1c36e2b..05df5a8 100644 --- a/test/babashka/cli_test.cljc +++ b/test/babashka/cli_test.cljc @@ -1129,7 +1129,7 @@ :spec {:recursive {:alias :r :desc "Delete recursively"}}}]] (testing "top level: usage, commands, options, pointer" (is (= (str "Usage: example [options] \n\n" - "Commands:\n copy Copy a file\n delete Delete a file\n\n" + "Commands:\n copy Copy a file\n delete Delete a file\n\n" "Options:\n -v, --verbose Verbose output\n\n" "Run \"example --help\" for more information on a command.") (cli/format-command-help {:table table :prog "example"})))) @@ -1176,7 +1176,7 @@ :epilog ["Examples:" " p go"]}]] (is (= (str "Usage: p \n\n" "Tool.\n\nSecond paragraph.\n\n" - "Commands:\n go Runs it.\n\n" + "Commands:\n go Runs it.\n\n" "Run \"p --help\" for more information on a command.") (cli/format-command-help {:table t :prog "p"}))) (is (= (str "Usage: p go\n\n" @@ -1214,7 +1214,7 @@ :dispatch [] :prog "tool" :tree (cli/table->tree table)})] (is (= (str "Unknown command: nope\n\n" - "Commands:\n dev Start dev.\n deps Dep tools\n\n" + "Commands:\n dev Start dev.\n deps Dep tools\n\n" "Run \"tool --help\" for more information.") s)))) (testing ":input-exhausted (incomplete multi-word command) renders the group's commands"