Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty usage prevents line breaks between options #173

Open
LiteracyFanatic opened this issue May 18, 2022 · 1 comment
Open

Empty usage prevents line breaks between options #173

LiteracyFanatic opened this issue May 18, 2022 · 1 comment

Comments

@LiteracyFanatic
Copy link

Description

The help message is formatted incorrectly when any of the options have an empty description.

Repro steps

Create a subcommand with empty argument descriptions. Then run the program and print the help message.

type KanjiArgs =
    | Strokes of int
    | Min_Strokes of int
    | Max_Strokes of int
    | Include_Stroke_Miscounts
    | Radicals of string
    | Skip_Code of string
    | Sh_Code of string
    | Four_Corner_Code of string
    | Deroo_Code of string
    | Reading of string
    | Nanori of string
    | Common_Only
    | Pattern of string
    interface IArgParserTemplate with
        member this.Usage =
            match this with
            | Strokes _ -> ""
            | Min_Strokes _ -> ""
            | Max_Strokes _ -> ""
            | Include_Stroke_Miscounts -> ""
            | Radicals _ -> ""
            | Skip_Code _ -> ""
            | Sh_Code _ -> ""
            | Four_Corner_Code _ -> ""
            | Deroo_Code _ -> ""
            | Reading _ -> ""
            | Nanori _ -> ""
            | Common_Only -> ""
            | Pattern _ -> ""

type Args =
    | [<CliPrefix(CliPrefix.None)>] Kanji of ParseResults<KanjiArgs>
    interface IArgParserTemplate with
        member this.Usage =
            match this with
            | Kanji _ -> ""

Expected behavior

The help message should be formatted with newlines between the options, like this.

USAGE: kensaku kanji [--help] [--strokes <int>] [--min-strokes <int>]
                     [--max-strokes <int>] [--include-stroke-miscounts]
                     [--radicals <string>] [--skip-code <string>]
                     [--sh-code <string>] [--four-corner-code <string>]
                     [--deroo-code <string>] [--reading <string>]
                     [--nanori <string>] [--common-only] [--pattern <string>]

OPTIONS:

    --strokes <int>        
    --min-strokes <int>    
    --max-strokes <int>    
    --include-stroke-miscounts
    --radicals <string>    
    --skip-code <string>   
    --sh-code <string>     
    --four-corner-code <string>
    --deroo-code <string>  
    --reading <string>     
    --nanori <string>      
    --common-only          
    --pattern <string>     
    --help                display this list of options.

Actual behavior

Instead the output looks like this.

USAGE: kensaku kanji [--help] [--strokes <int>] [--min-strokes <int>]
                     [--max-strokes <int>] [--include-stroke-miscounts]
                     [--radicals <string>] [--skip-code <string>]
                     [--sh-code <string>] [--four-corner-code <string>]
                     [--deroo-code <string>] [--reading <string>]
                     [--nanori <string>] [--common-only] [--pattern <string>]

OPTIONS:

    --strokes <int>           --min-strokes <int>       --max-strokes <int>       --include-stroke-miscounts
                              --radicals <string>       --skip-code <string>      --sh-code <string>        --four-corner-code <string>
                              --deroo-code <string>     --reading <string>        --nanori <string>         --common-only             --pattern <string>        --help                display this list of options.

Known workarounds

Using a single space instead of an empty string for the description causes newlines to be added, but there are gaps between some of the options. Here is an example using x instead of a space for visibility.


USAGE: kensaku kanji [--help] [--strokes <int>] [--min-strokes <int>]
                     [--max-strokes <int>] [--include-stroke-miscounts]
                     [--radicals <string>] [--skip-code <string>]
                     [--sh-code <string>] [--four-corner-code <string>]
                     [--deroo-code <string>] [--reading <string>]
                     [--nanori <string>] [--common-only] [--pattern <string>]

OPTIONS:

    --strokes <int>       x
    --min-strokes <int>   x
    --max-strokes <int>   x
    --include-stroke-miscounts
                          x
    --radicals <string>   x
    --skip-code <string>  x
    --sh-code <string>    x
    --four-corner-code <string>
                          x
    --deroo-code <string> x
    --reading <string>    x
    --nanori <string>     This is a very long description which needs to be
                          wrapped to multiple lines in order to fit
    --common-only         x
    --pattern <string>    x
    --help                display this list of options.

Related information

  • Linux
  • .NET 6.0.102
@dlidstrom
Copy link
Contributor

Nice bug report 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants