From 79f754a968798fac4fa5bb09129da5adf0973930 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 4 Nov 2021 20:41:58 +0100 Subject: Sort arguments lexicographically in command's help (#27196) --- lib/spack/spack/main.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') 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): -- cgit v1.2.3-70-g09d2