diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-11-13 10:17:54 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-11-13 10:59:30 +0100 |
commit | 51faf83696dec9de717f72534b2612ddfd752d4a (patch) | |
tree | 95949b327d64df45621ccf338828da4bb9662fce /src/ukify | |
parent | Merge pull request #29990 from Flowdalic/memory-zswap-current (diff) | |
download | systemd-51faf83696dec9de717f72534b2612ddfd752d4a.tar.xz systemd-51faf83696dec9de717f72534b2612ddfd752d4a.zip |
ukify: print a more readable synopsis in --help
The details of formatting are copied from mkosi. This results in the following:
usage:
ukify build [--linux=LINUX] [--initrd=INITRD] [options…]
ukify genkey [options…]
ukify inspect FILE… [options…]
Build and sign Unified Kernel Images
options:
--version show program's version number and exit
...
I put "[options…]" at the end, because that's what one would generally do
with long options like "--cmdline" and others.
Diffstat (limited to 'src/ukify')
-rwxr-xr-x | src/ukify/ukify.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index b09fb4d5cc..8006624f0a 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -70,6 +70,14 @@ EFI_ARCHES: list[str] = sum(EFI_ARCH_MAP.values(), []) DEFAULT_CONFIG_DIRS = ['/run/systemd', '/etc/systemd', '/usr/local/lib/systemd', '/usr/lib/systemd'] DEFAULT_CONFIG_FILE = 'ukify.conf' +class Style: + bold = "\033[0;1;39m" if sys.stderr.isatty() else "" + gray = "\033[0;38;5;245m" if sys.stderr.isatty() else "" + red = "\033[31;1m" if sys.stderr.isatty() else "" + yellow = "\033[33;1m" if sys.stderr.isatty() else "" + reset = "\033[0m" if sys.stderr.isatty() else "" + + def guess_efi_arch(): arch = os.uname().machine @@ -1161,7 +1169,7 @@ CONFIG_ITEMS = [ 'positional', metavar = 'VERB', nargs = '*', - help = f"operation to perform ({','.join(VERBS)})", + help = argparse.SUPPRESS, ), ConfigItem( @@ -1499,11 +1507,13 @@ class PagerHelpAction(argparse._HelpAction): # pylint: disable=protected-access def create_parser(): p = argparse.ArgumentParser( description='Build and sign Unified Kernel Images', + usage='\n ' + textwrap.dedent('''\ + ukify {b}build{e} [--linux=LINUX] [--initrd=INITRD] [options…] + ukify {b}genkey{e} [options…] + ukify {b}inspect{e} FILE… [options…] + ''').format(b=Style.bold, e=Style.reset), allow_abbrev=False, add_help=False, - usage='''\ -ukify [options…] VERB -''', epilog='\n '.join(('config file:', *config_example())), formatter_class=argparse.RawDescriptionHelpFormatter, ) |