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

Too much whitespace in output #3096

Closed
2 tasks done
epage opened this issue Dec 8, 2021 · 7 comments · Fixed by #3179
Closed
2 tasks done

Too much whitespace in output #3096

epage opened this issue Dec 8, 2021 · 7 comments · Fixed by #3179
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies S-waiting-on-decision Status: Waiting on a go/no-go before implementing
Milestone

Comments

@epage
Copy link
Member

epage commented Dec 8, 2021

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.55.0 (c8dfcfe04 2021-09-06)

Clap Version

3.0.0-rc.0

Minimal reproducible code

use structopt::StructOpt;

#[derive(StructOpt, Debug)]
#[structopt(author, about)]
struct Opt {}

fn main() {
    let opt = Opt::from_args();
    dbg!(opt);
}

Steps to reproduce the bug with the above code

cargo run -- --help

Actual Behaviour

test-clap 0.1.0      
                                                                         
Me                                                                       
                                    
From Cargo.toml
                                                                         
USAGE:                                                                   
    test-clap                       
                                                                         
OPTIONS:             
    -h, --help       Print help information                              
    -V, --version    Print version information                

Expected Behaviour

Note quite but similar to clap2 which is

test-clap 0.1.0                                                          
Me                   
From Cargo.toml
                                                                         
USAGE:                                                                   
    test-clap                       
                                                                         
FLAGS:               
    -h, --help       Prints help information                             
    -V, --version    Prints version information

Maybe

test-clap 0.1.0                                                          
Me                   

From Cargo.toml
                                                                         
USAGE:                                                                   
    test-clap                       
                                                                         
FLAGS:               
    -h, --help       Prints help information                             
    -V, --version    Prints version information

or

test-clap 0.1.0 - From Cargo.toml 
Me                   
                                                                         
USAGE:                                                                   
    test-clap                       
                                                                         
FLAGS:               
    -h, --help       Prints help information                             
    -V, --version    Prints version information

Additional Context

This came from reddit.

Debug Output

No response

@epage epage added C-bug Category: Updating dependencies A-help Area: documentation, including docs.rs, readme, examples, etc... labels Dec 8, 2021
@pksunkara
Copy link
Member

This is intentional IIRC because of #1432

@epage
Copy link
Member Author

epage commented Dec 9, 2021

Thanks for the context; I had assumed it was done for a reason but hadn't looked yet.

I still think this is worth having as an issue as it is a regression. We are balancing competing needs and maybe we can find a third way (without just adding a flag)

Granted, once we get proper man generation, it'll lower the reliance on help2man

@joshtriplett
Copy link
Contributor

This seems like a regression to me as well. Vertical space is precious in help output, especially for commands with lots of options or subcommands.

@epage
Copy link
Member Author

epage commented Dec 9, 2021

Here is an example of what help2man parses

$ foo --version
GNU foo 1.1

Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by A. Programmer.
$ foo --help
GNU `foo' does nothing interesting except serve as an example for
`help2man'.

Usage: foo [OPTION]...

Options:
  -a, --option      an option
  -b, --another-option[=VALUE]
                    another option

      --help        display this help and exit
      --version     output version information and exit

Examples:
  foo               do nothing
  foo --option      the same thing, giving `--option'

Report bugs to <bug-gnu-utils@gnu.org>.

From https://www.gnu.org/software/help2man/

@I60R
Copy link

I60R commented Dec 12, 2021

Looks ugly enough to stay with the current version of structopt instead.

Also, what is the point in having man page that completely mirrors --help output?

@epage
Copy link
Member Author

epage commented Dec 13, 2021

Also, what is the point in having man page that completely mirrors --help output?

I don't think the intent is to be exactly --help but to be a superset. help2man supports including additional content. Its fairly standard for man pages to include a --help like output, so its reasonable for wanting to generate that to keep it up to date just like people generate --help output.

@epage epage added the S-waiting-on-decision Status: Waiting on a go/no-go before implementing label Dec 13, 2021
@epage epage added this to the 3.0 milestone Dec 13, 2021
@epage
Copy link
Member Author

epage commented Dec 14, 2021

Random notes as I research help2man to see if there is any way to reconcile the two needs

help2man's docs sound like they want the organization to be

  1. usage
  2. about
  3. args
  4. additional help text (our after_long_help)
  5. examples
  6. contact or bug reporting

I'm also seeing this pattern in docker. vim shows user-facing name - version first with no about. git doesn't seem to provide a name or about. Trying to think of what other programs to look at.

I wonder what we can do to encourage examples

From help2man's docs

Use argv[0] for the program name in these synopses, just as it is, with no directory stripping. This is in contrast to the canonical (constant) name of the program which is used in --version.

Interesting. They want the usage to use argv[0] but everywhere else to the use actual name.

For us, we show the bin name as the application name (see #992). Our bin name is argv[0].file_name() though with #992 I am considering changing it to argv[0].file_stem() or similar.

From help2man's docs

It is usually best to alphabetise (by short option name first, then long) within each section, or the entire list if there are no sections.

Interesting input for #2808

Now in running help2man

clap2 output

.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.47.13.
.TH TEST-CLAP "1" "December 2021" "test-clap 0.1.0" "User Commands"      
.SH NAME
test-clap \- manual page for test-clap 0.1.0
.SH DESCRIPTION                  
test\-clap 0.1.0                                                         
Me                                                                       
From Cargo.toml                     
.SS "USAGE:"                                                             
.IP                                                                      
test\-clap                                                               
.SS "FLAGS:"                       
.TP                                 
\fB\-h\fR, \fB\-\-help\fR
Prints help information
.TP
\fB\-V\fR, \fB\-\-version\fR
Prints version information
.SH "SEE ALSO"
The full documentation for
.B test-clap
is maintained as a Texinfo manual.  If the
.B info
and
.B test-clap
programs are properly installed at your site, the command
.IP
.B info test-clap
.PP
should give you access to the complete manual.

clap3 output

.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.47.13.
.TH TEST-CLAP "1" "December 2021" "test-clap 0.1.0" "User Commands"
.SH NAME
test-clap \- manual page for test-clap 0.1.0
.SH DESCRIPTION
test\-clap 0.1.0
.PP
Me
.PP
From Cargo.toml
.SS "USAGE:"
.IP
test\-clap
.SS "OPTIONS:"
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help information
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version information
.SH "SEE ALSO"
The full documentation for
.B test-clap
is maintained as a Texinfo manual.  If the
.B info
and
.B test-clap
programs are properly installed at your site, the command
.IP
.B info test-clap
.PP
should give you access to the complete manual.

The only difference is the insertion of .PP. It looks like this is just about having paragraph marks between distinct data so it doesn't merge the lines.

Between people being able to override the help template (including when just code-genning their man page) and #3174, I'm inclined to revert the template change in #2369, so we go back to the clap2 output.

That said, I am all for ideas for overall improvement of the help output!

epage added a commit to epage/clap that referenced this issue Dec 15, 2021
The extra whitespace was targeted at machine processing for a subset of
users for a subset of runs of CLIs.  On the other hand, there is a lot
of concern over the extra verbose output.

A user can set the help template for man, if desired.  They can even do
something (env? feature flag?) to make it only run when doing man
generation.  We also have clap-rs#3174 in the works.

So let's focus on the end-user reading `--help`.  People wanting to use
`help2man` have workarounds to do what they need.

Fixes clap-rs#3096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies S-waiting-on-decision Status: Waiting on a go/no-go before implementing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants