From ef2c6cb157f47311107ea7571a9cc43f509efe32 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 12 Oct 2023 09:57:24 -0500 Subject: [PATCH] Enabled amd-smi auto completion using argcomplete Signed-off-by: Maisam Arif Change-Id: I0ea48b1b3a10e738d1fe91db85bc61ad51b85de2 [ROCm/amdsmi commit: d6abcfa92d42049ee11a6b9a12763caa2aef0d7d] --- projects/amdsmi/amdsmi_cli/amdsmi_cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py index 3a88ae5acc..3bafe179ca 100755 --- a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK + # # Copyright (C) 2023 Advanced Micro Devices. All rights reserved. # @@ -23,6 +25,11 @@ import logging import sys +try: + import argcomplete +except ImportError: + logging.debug("argcomplete module not found. Autocomplete will not work.") + from amdsmi_commands import AMDSMICommands from amdsmi_parser import AMDSMIParser from amdsmi_logger import AMDSMILogger @@ -63,6 +70,11 @@ if __name__ == "__main__": amd_smi_commands.reset, amd_smi_commands.rocm_smi) try: + try: + argcomplete.autocomplete(amd_smi_parser) + except NameError: + logging.debug("argcomplete module not found. Autocomplete will not work.") + args = amd_smi_parser.parse_args(args=None if sys.argv[1:] else ['--help']) # Handle command modifiers before subcommand execution