comonicon / Comonicon.jl

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

[BUG] Help text wraps; terminal width not detected correctly #263

Open jakobnissen opened 10 months ago

jakobnissen commented 10 months ago

A script with the following content:

using Comonicon

"""
# Intro
Benchmark a set of bins agains a reference

# Args
- `ref`: Path to reference JSON file (see the `makeref subcommand`)
- `bins`: Paths to TSV files of bins.

# Options
- `-r, --rank`: Taxonomic rank to benchmark
- `-s, --sep`: Binsplit separator; delimiter to split bins
- `--minsize`: Remove bins with shorter breadth
- `--minseqs`: Remove bins fewer sequences
- `--keep-flags`: Only keep genomes with all these flags set.
  Takes a comma-separated list of flags, e.g. "virus,plasmid"
- `--remove-flags`: Remove genomes with any of these flags set. See above.
- `--recalls`: Comma-separated list of recall thresholds to use
- `--precisions`: Comma-separated list of precision thresholds to use

# Flags
- `--assembly`: Count number of recovered assemblies, not genomes
- `--intersect`: Allow the same sequence to be in multiple bins
"""
Comonicon.@main function bench(
    ref::String,
    bins...; # TODO: Explicit type here, but Comonicon issue #261 prevents this
    rank::Int=0,
    sep::Union{String, Nothing}=nothing,
    minsize::Int=1,
    minseqs::Int=1,
    keep_flags::String,
    remove_flags::String,
    recalls::Vector{Float64}=[0.6, 0.7, 0.8, 0.9, 0.95, 0.99],
    precisions::Vector{Float64}=[0.6, 0.7, 0.8, 0.9, 0.95, 0.99],
    assembly::Bool=false,
    intersect::Bool=false,
)
    nothing
end

And invoked like this: julia --startup=no --project=. foo.jl -h. You can see in the screenshot below that the description for e.g. keep-flags wraps around, presumably because the display size is incorrectly computed.

Version of the package: This is on Comonicon 1.0.6.

Expected behavior I would expect the text to not wrap all the way to the left of the screen, but wrap on the right side, where the descriptions are.

Screenshots Screenshot from 2023-10-25 15-57-15

Roger-luo commented 10 months ago

hmm, this is not expected, I guess something went wrong in detecting the displaysize, we just use this to detect the size, if your width is smaller than 80 however, we currently will use 80 instead. It might be better to see if we can provide a more compact printing instead of doing everything two column.

jakobnissen commented 10 months ago

But I have:

julia> displaysize(stdout)
(55, 106)