You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importargparseimportargcompleteimportosdefdirectory_completer(prefix, parsed_args, **kwargs):
# Return a list of directories in the current directoryreturn [dfordinos.listdir('.') ifos.path.isdir(d) andd.startswith(prefix)]
defmain():
parser=argparse.ArgumentParser(description="Example script with dynamic tab completion")
# Add an argument that uses the directory completerparser.add_argument('--dir', help='Directory argument').completer=directory_completer# Integrate argcompleteargcomplete.autocomplete(parser)
args=parser.parse_args()
print(f"Directory: {args.dir}")
There is a module that can make arguments autocomplete
However you need to do some stuff outside python:
We have to install argcomplete + activate it on a machine (Question: How do we do this inside the pip setup stuff?)
This goes inside every code that has arguments
The text was updated successfully, but these errors were encountered: