Consider an absent `:prog` for command help

Open Beginner friendly
#233 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
clojure
Domain
cli

Research direction

Start with the cli/dispatch path that formats help output when no :prog option is supplied, using the reproduction in the issue. Check the generated Usage and Run lines, then add regression coverage for the absent-program case. Done means both lines omit the unwanted extra space while the existing command help remains unchanged.

Written by the indexing model from the issue text.

Description

Scenario

Sometimes a program does not have a clear usage name.

For example, a program might be invoked via clojure -M:cli <some-command> [some-options].

In these cases, I don't specify :prog as a dispatch option.
bb cli lets me do this, but it results in an (admittedly nitpicky) output formatting issue.

Repro

For example:

(require '[babashka.cli :as cli])

(cli/dispatch {:cmd {"foo" {:fn identity
                            :doc "foo command help"}}}
              ["--help"]
              {:help true})

Outputs:

Usage:  [options] <command>

Commands:
  foo  foo command help

Options:
  -h, --help  Show this help

Run " <command> --help" for more information on a command.

It's a minor quibble, but notice the extra space before [options] in Usage: [options].
And after Run " on the last line.

Proposal

If :prog is not specified, don't display an extra space character in formatted outputs.

Next

Happy to do up a PR if this seems interesting to you.

Dominant language
Clojure
Stars
293
Forks
22
Avg merge
13m
Merged PRs (30d)
11

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.