summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-06-22 23:41:51 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2018-06-24 10:19:07 -0700
commitf476e60c01de00fa361acf69259f32ec3f2165ba (patch)
tree0410704301bfcfa48d204ae200b518a3f91cf85a /lib
parentdf45b6f56db3dde44b80ee433bfdb1de7e921b31 (diff)
downloadspack-f476e60c01de00fa361acf69259f32ec3f2165ba.tar.gz
spack-f476e60c01de00fa361acf69259f32ec3f2165ba.tar.bz2
spack-f476e60c01de00fa361acf69259f32ec3f2165ba.tar.xz
spack-f476e60c01de00fa361acf69259f32ec3f2165ba.zip
Add `spack -H` shortcut for `spack help --all`
- I keep typing this based on `spack test -h` and `spack test -H` - This finally makes my fingers happy
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/main.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 61e992bed4..6a3f964ab8 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -314,9 +314,14 @@ def make_argument_parser(**kwargs):
stat_lines = list(zip(*(iter(stat_names),) * 7))
parser.add_argument(
- '-h', '--help', action='store_true',
+ '-h', '--help',
+ dest='help', action='store_const', const='short', default=None,
help="show this help message and exit")
parser.add_argument(
+ '-H', '--all-help',
+ dest='help', action='store_const', const='long', default=None,
+ help="show help for all commands (same as spack help --all)")
+ parser.add_argument(
'--color', action='store', default='auto',
choices=('always', 'never', 'auto'),
help="when to colorize output (default: auto)")
@@ -563,15 +568,17 @@ def main(argv=None):
parser.print_help()
return 1
- # -h and -V are special as they do not require a command, but all the
- # other options do nothing without a command.
- if not args.command:
- if args.version:
- print(spack.spack_version)
- return 0
- else:
- parser.print_help()
- return 0 if args.help else 1
+ # -h, -H, and -V are special as they do not require a command, but
+ # all the other options do nothing without a command.
+ if args.version:
+ print(spack.spack_version)
+ return 0
+ elif args.help:
+ sys.stdout.write(parser.format_help(level=args.help))
+ return 0
+ elif not args.command:
+ parser.print_help()
+ return 1
# Try to load the particular command the caller asked for. If there
# is no module for it, just die.
@@ -586,14 +593,6 @@ def main(argv=None):
# Re-parse with the proper sub-parser added.
args, unknown = parser.parse_known_args()
- # we now know whether options go with spack or the command
- if args.version:
- print(spack.spack_version)
- return 0
- elif args.help:
- parser.print_help()
- return 0
-
# now we can actually execute the command.
command = spack.cmd.get_command(cmd_name)
try: