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

Create a man page #244

Open
casey opened this issue Nov 15, 2017 · 10 comments
Open

Create a man page #244

casey opened this issue Nov 15, 2017 · 10 comments

Comments

@casey
Copy link
Owner

casey commented Nov 15, 2017

The readme can be converted to a man page:

http://asciidoctor.org/docs/user-manual/#man-pages

Would be nice to get command examples directly from clap. Also remember to include the grammar.

@casey casey modified the milestones: soon, now Apr 17, 2019
@casey casey modified the milestones: 1.0, soon May 27, 2019
@casey
Copy link
Owner Author

casey commented Jun 23, 2019

Working on this, but it's ballooned into a huge and messy diff that refactors command line option handling and command launching.

I need to:

  • rebase onto current master
  • change name of the new Config struct to Options
  • factor write tests for new arg parser
  • factor in environment
  • actually write the feature I set out to write

@Th3Whit3Wolf
Copy link

Would there be in any interest in using clap to generate the man page? This is from the Rust CLI WG.

@casey
Copy link
Owner Author

casey commented Jul 3, 2019

I'd definitely like to use clap to generate the command-line option section of the man page!

@Th3Whit3Wolf
Copy link

Since generating a man page with clap relies on using a non-master git version I have experimented with other avenues.

man

I played with man but the way they display options seemed not quite ideal (In retrospect I could probably have made it work with a custom section).

Enter roff-rs

I saw man's only dependency was roff-rs so I checked it out. It's a little more verbose but can pretty easily make whatever you want.

I have so far basically converted the just --help output into a man page that com

JUST(1)                                      General Commands Manual                                     JUST(1)

NAME
       just - Just a command runner

SYNOPSIS
       just [FLAGS] [OPTIONS] [--] [ARGUMENTS]...

DESCRIPTION
       just is a simple, fast and user-friendly alternative to make(1)

FLAGS
       --dry-run
              Print what just would do without doing it

       --dump Print entire justfile

       -e, --editor
              Open justfile with $EDITOR

       --evaluate
              Print evaluated variables

       --highlight
              Highlight echoed recipe lines in bold

       -l, --list
              List available recipes and their arguments

       -q, --quiet
              Suppress all output

       --summary
              List names of available recipes

       -v, --verbose
              Use verbose output

       -h, --help
              Print help information

       -V, --version
              Use version information

OPTIONS
       --color COLOR
              Print colorful output [default: auto] [possible values: auto, always, never]

       -f, --justfile JUSTFILE
              Use JUSTFILE as justfile

       --set VARIABLE VALUE
              Set VARIABLE to VALUE

       --shell SHELL
              Invoke SHELL to run recipes [default: sh]

       -s, --show RECIPE
              Show information about RECIPE

       -d, --working-directory WORKING-DIRECTORY
              Use WORKING-DIRECTORY as working directory. --justfile must also be set

                                                                                                         JUST(1)

Thoughts

Would you be interested in this kind of implementation?
If so what else would you like to have in it?
It should be noted that as of this moment the man page is created on run not build, so it would need to be ran from a seperate binary on install.

@casey
Copy link
Owner Author

casey commented Jul 3, 2019

For the command line options, I'd like to use clap, just because otherwise it'll be easy for the man page and the actual command line parser to get out of date. I think man page generation will land in Clap 3.0, which will probably take a while though, so I'm planning on just generating the non-command-line-option part of the man page now, using asciidoctor to convert the readme, since asciidoctor already has a man page backend.

@bb010g
Copy link

bb010g commented Jul 30, 2019

My last encounter with this sort of thing ended up in mdoc-to-md, which converts mandoc-package real manual pages (because all the converters I looked at had weird quirks) to Markdown. This allows you to just cat the manual page to a README header and keep things in sync. (It needs updating to a newer mandoc version, but is still operable & consistent thanks to the pinned Nix stuff in there in the meantime.)

@casey
Copy link
Owner Author

casey commented Jul 30, 2019

@bb010g That looks promising. Thank you very much for the tip!

@casey casey modified the milestones: soon, eventually Oct 13, 2019
@casey casey modified the milestones: eventually, 1.0 Nov 7, 2019
@casey casey modified the milestones: 1.0, eventually Nov 21, 2019
@casey casey removed this from the eventually milestone Jul 2, 2020
@tgross35
Copy link
Contributor

tgross35 commented Mar 4, 2024

An update from the future, https://crates.io/crates/clap_mangen is a pretty sane choice nowadays. Probably a reasonable thing to add after #1924 finishes up.

@casey
Copy link
Owner Author

casey commented May 15, 2024

@tgross35 Nice! I just merged #2041, which generates the man page with clap_mangen (we were using help2man before).

It would still be nice to get the readme in there, but I think converting the markdown to sensible roff will require some work.

@tgross35
Copy link
Contributor

mandown can do markdown->roff which IIRC works reasonable but it isn't very flexible. Maybe something through roff could be used to glue the mandown output to that of clap_mangen?

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

4 participants