summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-11-04 20:41:58 +0100
committerGitHub <noreply@github.com>2021-11-04 12:41:58 -0700
commit79f754a968798fac4fa5bb09129da5adf0973930 (patch)
tree6a9bd6a912c95dea6ed630fdcd08cf83604143e2 /lib
parent084ce461075f1cfc4319c51503127b1f1c12a082 (diff)
downloadspack-79f754a968798fac4fa5bb09129da5adf0973930.tar.gz
spack-79f754a968798fac4fa5bb09129da5adf0973930.tar.bz2
spack-79f754a968798fac4fa5bb09129da5adf0973930.tar.xz
spack-79f754a968798fac4fa5bb09129da5adf0973930.zip
Sort arguments lexicographically in command's help (#27196)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/main.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 1eeec8827b..31a4bfe4ed 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -12,6 +12,7 @@ from __future__ import print_function
import argparse
import inspect
+import operator
import os
import os.path
import pstats
@@ -188,6 +189,10 @@ class SpackHelpFormatter(argparse.RawTextHelpFormatter):
usage = '[-%s] %s' % (chars, usage)
return usage.strip()
+ def add_arguments(self, actions):
+ actions = sorted(actions, key=operator.attrgetter('option_strings'))
+ super(SpackHelpFormatter, self).add_arguments(actions)
+
class SpackArgumentParser(argparse.ArgumentParser):
def format_help_sections(self, level):