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

make indentation of descriptions configurable or even automatic #258

Closed
bfrk opened this issue Apr 24, 2017 · 4 comments
Closed

make indentation of descriptions configurable or even automatic #258

bfrk opened this issue Apr 24, 2017 · 4 comments

Comments

@bfrk
Copy link

bfrk commented Apr 24, 2017

In the help output, the description text for an option or command is currently indented to a hard-coded value of 24 (plus the initial indent of 2). This tends to waste horizontal space if the option or command names are short.

It would nice (and probably easy) to add a new prefDescIndent :: Int field to ParserPrefs.

Even nicer would be to determine this automatically from the maximum length of the option and command names, which is what the help formatter of GetOpt does. It might be challenging to implement this in a compositional way, since we want to have the same indentation for all groups of items. For example, instead of

Usage: example COMMAND
  Do something

Available options:
  -h,--help                Show this help text

Available commands:
  doit                     Complicated explanation of what this command can,         
                           will, or won't do
  modify                   Another command with an explanation

we would get:

Usage: example COMMAND
  Do something

Available options:
  -h,--help  Show this help text

Available commands:
  doit       Complicated explanation of what this command can, will, or won't do
  modify     Another command with an explanation
@HuwCampbell
Copy link
Collaborator

This seems like a reasonable request, and the first part would be rather easy as you say.

The second suggestion might be a good deal more difficult though, I don't think that the Wadler pretty printing libraries actually support layouts like this.

@bfrk
Copy link
Author

bfrk commented Apr 26, 2017

It should not matter. We just have to calculate the common maximum of /everything/ that goes in the left column (up to a user defined limit) so we can use this number as input to whatever combinator creates the option/command listings. Assuming that optparse-applicative internally works with a deep embedding i.e. builds some kind of "syntax" tree, this would amount to an extra pass over the tree prior to creating the help Doc.

Hm, implementing this might be fun. I think i will give it a try...

@HuwCampbell
Copy link
Collaborator

Yeah I wasn't saying it's impossible, just trickier that it would be if there was more native support for it in the pp library.

Cool, feel free to have a crack.

@HuwCampbell
Copy link
Collaborator

Closing as this has been addressed with #407 and will be in 0.17.

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

No branches or pull requests

2 participants