argparse::ArgumentParser knows all possible arguments. It should therefore be possible to add a function argparse::ArgumentParser::generate_complete_script(command_name, shell) that generates a complete script which allows elaborate tab completion for the given command's arguments in the given shell.
See https://www.gnu.org/software/bash/manual/bash.html#A-Programmable-Completion-Example for an example of a complete script. The example is for bash specifically. Other terminals have other ways to complete, but it should be one that other terminals support the scripts of to also provide tab-completion.
To support this well, it makes sense to add an option .file() similar to the existing .required() to specify that an option expects an existing file name, which will then result in the appropriate complete script syntax which then makes bash complete existing files. .choices also lends itself well to tab-completion.
git is an example of a program that does this and it's very neat. git + tab will show a list of subcommands and git add + tab shows a list of files that can be added. If you use the terminal fish the completion is even better (showing only files that make sense to add, not all files for example) because it allows for full dynamic scripting instead of just a fixed set of options. Powershell is probably also worth supporting.
argparse::ArgumentParserknows all possible arguments. It should therefore be possible to add a functionargparse::ArgumentParser::generate_complete_script(command_name, shell)that generates a complete script which allows elaborate tab completion for the given command's arguments in the given shell.See https://www.gnu.org/software/bash/manual/bash.html#A-Programmable-Completion-Example for an example of a complete script. The example is for bash specifically. Other terminals have other ways to complete, but it should be one that other terminals support the scripts of to also provide tab-completion.
To support this well, it makes sense to add an option
.file()similar to the existing.required()to specify that an option expects an existing file name, which will then result in the appropriate complete script syntax which then makes bash complete existing files..choicesalso lends itself well to tab-completion.gitis an example of a program that does this and it's very neat.git+ tab will show a list of subcommands andgit add+ tab shows a list of files that can be added. If you use the terminal fish the completion is even better (showing only files that make sense to add, not all files for example) because it allows for full dynamic scripting instead of just a fixed set of options. Powershell is probably also worth supporting.