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

Improve the Spack command reference #7214

Merged
merged 6 commits into from
Feb 13, 2018
Merged

Conversation

tgamblin
Copy link
Member

@tgamblin tgamblin commented Feb 11, 2018

This improves the command reference in the docs. Previously, the command reference listed only commands for which we explicitly wrote documentation. Now it lists all Spack commands and shows their usage. This was sort of inspired by the Docker CLI reference.

This also contains a number of improvements to spack <cmd> -h output.

  • Add a spack commands command to list commands in various formats (including RST)
  • Rework the docs to use spack commands to generate the command reference. Docs now have an index by type of command and show full usage.
  • Add proper help for spack buildcache subcommands
  • Fix some bugs with spack -h argument display
  • Display options in help output as [-abc], not [-a] [-b] [-c]
  • Clean up the metavar for --scope arguments in configuration commands like mirror, repo, etc. (it's now much shorter)

You can look at a preview here.

@JusticeForMikeBrown: you might like this, as it would've saved you a few issue submissions.

- previously commands with this argument showed a long list of choices
  that were platform specific.

- use a better metavar: {defaults,system,site,user}[/PLATFORM]
@tgamblin tgamblin added documentation Improvements or additions to documentation commands labels Feb 11, 2018
- Add proper help for `spack buildcache` subcommands

- Reorganize the help categories of Spack commands so that buildcache is
  in packaging and diy and setup are now in build.
- Shorten Spack command usage for short options. Short options are now
  shown as [-abc] instead of as [-a] [-b] [-c]

- fix bug that mixed long and short options for top-level `spack help`
@tgamblin tgamblin force-pushed the features/better-command-index branch 2 times, most recently from a75299b to 5119d90 Compare February 12, 2018 07:56
- command reference now includes usage for all Spack commands as output
  by `spack help`.  Each command usage links to any related section in
  the docs.

- added `spack commands` command which can list command names,
  subcommands, and generate RST docs for commands.

- added `llnl.util.argparsewriter`, which analyzes an argparse parser and
  calls hooks for description, usage, options, and subcommands
@tgamblin tgamblin force-pushed the features/better-command-index branch from 5119d90 to 363c32a Compare February 12, 2018 08:24
@adamjstewart
Copy link
Member

This is cool. Is it possible to add short and long descriptions to argparse commands? What I'm envisioning is that when you run spack help, you get the name and short description of every command, but when you run spack help list, you get the short and long description of the command. The long description would be similar to a man page, with detailed examples of common usage. Of course, someone would need to write these long descriptions, but it would get us one step closer to a future where if you ever have a question about how to use a command, spack help <command> gives you everything you need to know.

@tgamblin tgamblin closed this Feb 12, 2018
@tgamblin tgamblin reopened this Feb 12, 2018
@tgamblin
Copy link
Member Author

@adamjstewart: it's possible in the sense that we could add a long help attribute to commands, but we'd need to rework the help formatter to do it. We already have a custom help formatter in spack.main.SpackHelpFormatter, so it wouldn't be too hard.

Then again, I think other tools tend to deal with this differently. git and brew use manpages for this, and it may be that we should just write longer rst sections for each command, turn them into manpages, and have spack help <cmd> give you the manpage like git help <cmd> does, and keep the short descriptions in spack <cmd> -h. I actually like the rst way better because there's room for more detail and there are well defined rules for formatting the long help. Wedging all this into argparse alone seems like a lot of work for only a little gain when there are more versatile ways to do the same thing.

Thoughts?

@tgamblin tgamblin merged commit b98cdf0 into develop Feb 13, 2018
@tgamblin tgamblin deleted the features/better-command-index branch May 15, 2018 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commands documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants