Skip to content

Any interest in supporting multiline cells in usage help? #119

@lread

Description

@lread

Intro

I very happily use babaskha.cli on several projects. ❤

Sometimes my usage help gets a bit wide, so I customize babashka.cli output, and one thing I do is support multiline cells in usage help.

Here's a work in progress for antq:

antq ARG USAGE:
 [options..]

      --upgrade                                   Upgrade outdated versions interactively
      --force                                     Use with upgrade for non-interactive upgrade
      --exclude=<artifact-name[@version]>         Skip version checking for specified artifacts or versions
                                                   for multiple, repeat arg, ex: --exclude=art1 --exclude=art2@1.23
                                                   or use colon separators: --exclude=art1:art2@1.23
 -d,  --directory=<directory>                     Add search paths for projects (in addition to ./)
                                                   default: ./
                                                   for multiple, repeat arg, ex: --directory=./dira --directory=./dirb
                                                   or use colon separators: --directory=./dira:./dirb
      --focus=<artifact-name>                     Only version check for specified artifacts
                                                   for multiple, repeat arg, ex: --focus=art1 --focus=art2
                                                   or use colon separators: --focus=art1:art2
      --skip=<babashka|boot|circle-ci             Skip specified project file types
              |clojure-cli|github-action           for multiple, repeat arg, ex: --format=pom --format=gradle
              |gradle|leiningen|pom|shadow-cljs>   or use colon separators: --format=pom:gradle
      --error-format=<error format>               Customize output for outdated dependencies
      --reporter=<table|format|json|edn>          Report output format
                                                   default: table
      --download                                  Download updated dependencies
      --ignore-locals                             Ignore versions installed in your local maven repository
      --check-clojure-tools                       Detect outdated clojure tools in ~/.clojure/tools
      --no-changes                                Skip checking changes between deps versions
      --changes-in-table                          Show changes URLs in table when using table reporter
      --transitive                                Scan outdated transitive deps
 -h,  --help                                      Show usage help

Proposal

Update format-table to wrap cells on newlines in cells within cell boundaries.
Nothing fancy. No auto-wrapping within cells. No auto-indenting within cells.

For this:

(-> (format-table {:rows [["r1c1\nr1c1 l2" "r1c2" "r1c3"]
                          ["r2c1 wider" "r2c2\nr2c2 l2\nr2c2 l3" "r2c3\nr2c3 l2"]
                          ["r3c1" "r3c2 wider" "r3c3\nr3c3 l2\nr3c3 l3"]]})
     str/split-lines)

Instead of this:

;; => ["  r1c1"
;;     "r1c1 l2 r1c2                 r1c3"
;;     "  r2c1 wider   r2c2"
;;     "r2c2 l2"
;;     "r2c2 l3 r2c3"
;;     "r2c3 l2"
;;     "  r3c1         r3c2 wider           r3c3"
;;     "r3c3 l2"
;;     "r3c3 l3"]

We'd get something like this:

;; => ["  r1c1        r1c2        r1c3"
;;     "  r1c1 l2"
;;     "  r2c1 wider  r2c2        r2c3"
;;     "              r2c2 l2     r2c3 l2"
;;     "              r2c2 l3"
;;     "  r3c1        r3c2 wider  r3c3"
;;     "                          r3c3 l2"
;;     "                          r3c3 l3"]

Next Steps

If you like the idea, I'd be happy to do up a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions