comonicon / Comonicon.jl

Your best CLI generator in JuliaLang
https://comonicon.org
MIT License
282 stars 25 forks source link

Add an option in printing to turn on/off double spacing in help message #275

Open MilesCranmer opened 4 months ago

MilesCranmer commented 4 months ago

My package AirspeedVelocity.jl has its help message with double lined spaces:

Screenshot 2024-04-25 at 12 54 18

It's been this way for a while but I'm adding more arguments now and its filling up beyond the terminal screen.

Is this expected? Is there any way to have it give single lined spaces instead?

Here is the command: https://github.com/MilesCranmer/AirspeedVelocity.jl/blob/master/src/BenchPkg.jl#L40. I see the double spacing this in both zsh and nushell.

Roger-luo commented 4 months ago

yes, there are only two columns at the moment.

MilesCranmer commented 4 months ago

Sorry what I meant is the vertical spacing – seems to have a lot of space between each argument (especially at the top):

Compared to a regular man page:

Screenshot 2024-04-25 at 17 31 12

and, e.g., julia itself:

Screenshot 2024-04-25 at 17 31 32
Roger-luo commented 4 months ago

you mean no space between commands? Or there is double space before Usage?

MilesCranmer commented 4 months ago

Right now it gets printed like this:

  benchpkg

Usage

  benchpkg <args> [options] [flags]

Args

  [package_name]                                            Name of the package. If not given, will be inferred.

Options

  -r, --rev <arg>                                           Revisions to test (delimit by comma). Use dirty to
                                                            benchmark the current state of the package at path
                                                            (and not a git commit). If not given, will be inferred based
                                                            on context.

  -o, --output-dir <arg>                                    Where to save the JSON results.

  -s, --script <arg>                                        The benchmark script. Default:
                                                            benchmark/benchmarks.jl downloaded from
                                                            stable.

  -e, --exeflags <arg>                                      CLI flags for Julia (default: none).

  -a, --add <arg>                                           Extra packages needed (delimit by comma).

  --url <arg>                                               URL of the package.

  --path <arg>                                              Path of the package.

  --bench-on <arg>                                          If the script is not set, this specifies the revision at
                                                            which to download benchmark/benchmarks.jl from the
                                                            package.

  -f, --filter <arg>                                        Filter the benchmarks to run (delimit by comma).

  --nsamples-load-time <arg>                                Number of samples to take when measuring load time of the
                                                            package (default: 5). (This means starting a Julia process
                                                            for each sample.)

Flags

  --tune                                                    Whether to run benchmarks with tuning (default: false).

  -h, --help                                                Print this help message.
  --version                                                 Print version.

I would like it to get printed as this:

  benchpkg

Usage
  benchpkg <args> [options] [flags]

Args
  [package_name]                                            Name of the package. If not given, will be inferred.

Options
  -r, --rev <arg>                                           Revisions to test (delimit by comma). Use dirty to
                                                            benchmark the current state of the package at path
                                                            (and not a git commit). If not given, will be inferred based
                                                            on context.
  -o, --output-dir <arg>                                    Where to save the JSON results.
  -s, --script <arg>                                        The benchmark script. Default:
                                                            benchmark/benchmarks.jl downloaded from
                                                            stable.
  -e, --exeflags <arg>                                      CLI flags for Julia (default: none).
  -a, --add <arg>                                           Extra packages needed (delimit by comma).
  --url <arg>                                               URL of the package.
  --path <arg>                                              Path of the package.
  --bench-on <arg>                                          If the script is not set, this specifies the revision at
                                                            which to download benchmark/benchmarks.jl from the
                                                            package.
  -f, --filter <arg>                                        Filter the benchmarks to run (delimit by comma).
  --nsamples-load-time <arg>                                Number of samples to take when measuring load time of the
                                                            package (default: 5). (This means starting a Julia process
                                                            for each sample.)
Flags
  --tune                                                    Whether to run benchmarks with tuning (default: false).
  -h, --help                                                Print this help message.
  --version                                                 Print version.

To save on vertical space.

Roger-luo commented 4 months ago

The proposed format here looks too dense to me when the description is long, it's hard to tell which text belong to which option, which was why I put space in between, so it's not a bug it's a feature... I'm OK with having an option to turn this on/off. But I currently don't have the capacity to work on it. I'm preparing my defense. It shouldn't be too hard to add it here: https://github.com/comonicon/Comonicon.jl/blob/main/src/ast/printing.jl#L51

MilesCranmer commented 4 months ago

it's hard to tell which text belong to which option

I agree with that – I think it would also be nice to reduce the margin in the middle. See the Julia help menu:

image

It's nice because (a) it fits in my terminal window, and (b) you can still associate text and options.

Roger-luo commented 4 months ago

yeah, it's prob because the two columns are too far. I agree with that.