I have a python script that takes in several files as required arguments, which I parse with argparse
.
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--imgtfile", required=True, help="IMGT file")
parser.add_argument("-s", "--fastqfile", required=True, help="FASTQ file")
parser.add_argument("-g", "--gene", required=True, help="Gene to extract")
parser.add_argument("-o", "--outfile", help="name of the output file")
# ... more arguments
argcomplete.autocomplete(parser) # <-- this doesn't help
args = parser.parse_args()
The issue is that the files have pretty long and annoying names. Shell tab expansion works great if the arguments are positional (i.e. no flags) but if I have flags the tab expansion doesn't work anymore. On the other hand I'd like to keep the flags to not hardcode the order of arguments.
I have looked into argcomplete
but can't really get it to work the way I like. It seems like I either need the choices
option in add_argument
, and/or fiddle with bash to enable global completion.
Since I am working remotely on a server, I'm a bit conservative about this. Seems to me as if there should be a simpler way. Any suggestions?