I have a custom Python module installed that I want to modify so that it provides an auto-complete function similar to other bash programs so that when the Tab
key is pressed a list of variables is printed out or a value is placed in the terminal. I'm not really running in a traditional sense but rather typing the name of the module which is aliased to run a conda environment yada yada. Is
there anyway to get argparse answer with parameter values? For example: after typing python3 ./module rollback -c
and pressing tab
could I list out some strings?
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='command')
rollback = subparsers.add_parser('rollback', help='Rollback to previous commit')
rollback.add_argument('-c', '--commit', dest='incomingCommitHash', default=None, type=str, required=False, help='Commit to deploy')