lambdaisland / cli

Opinionated command line argument handling, with excellent support for subcommands
Mozilla Public License 2.0
22 stars 1 forks source link

clojure fn doc on multiple lines does not get show in CLI help #2

Open ieugen opened 6 months ago

ieugen commented 6 months ago

Hi,

Having something like this:

(defn verify
  "Verifies a certificate isn't expired and
   was signed by a trusted authority."
  [flags]
  (not-implemented))

gives something like this:

  ca       Create a self signed certificate authority
  keygen   Create a public/private key pair.         
  sign     Create and sign a certificate.            
  pring    Print details about a certificate         
  verify   Verifies a certificate isn't expired and 

As you can see the second line in verify is not printed.

Not sure how important it is to fix but I think it could be documented so users are not taken by surprise.

The main complaint IMO would be the surprise factor and juggling with linters / line too long issue.

Otherwise, nice project so far - currently exploring it.

ieugen commented 6 months ago

This also happens to flags:

                 :commands ["ca" #'ca
                            "keygen" #'keygen
                            "sign" #'sign
                            "pring" #'my-print
                            "verify" {:command #'verify
                                      :flags ["--ca FILE" "Required: path to a file
                                                           containing one or more ca certificates"
                                              "--crt FILE" "Required: path to a file containing a single certificate"]}]}))

Gives me (notice description for --ca) :

  -V,              Prints the version                                      
  -h, --help       Prints this help message                                
      --ca FILE    Required: path to a file                                
      --crt FILE   Required: path to a file containing a single certificate
plexus commented 6 months ago

This is by design, we follow the same convention as for docstrings. Summary on the first line, longer explanation below that. You get the full docs for a command when you ask for its help.

For flags we don't surface that currently, maybe for flags it does make more sense to render the whole string, although then we'd also have to get smarter at aligning the different lines of text nicely.