I’m encountering an issue with file path autocompletion in my Python script that uses the argparse
module with several nested subparsers. I have enabled autocompletion using argcomplete
, but instead of suggesting file paths, it suggests other optional parameters.
The structure of my subparsers is as follows:
metaOp.py [--version] [-h]
├─┬╴local [-h]
│ ├─┬╴org [-h]
│ │ ├─╴mkOrg --alias Alias_1...Alias_N [--base-org OrgBaseDir] [-f] [-h] [-n]
│ │ ├─╴cleanOrg --alias Alias_1...Alias_N [--base-org OrgBaseDir] [-h]
│ │ ╰─╴openOrg --alias Alias_1...Alias_N [--base-org OrgBaseDir] [-h]
│ ╰─┬╴package [-h]
│ ├─╴mkPack --name NAME [--delSrc DelSrc...DelSrc_N] [--src Src...Src_N] [-h]
│ ├─╴sortPack --xml Xml1...XmlN [--inplace] [-h] [-o]
│ ╰─╴filterPack --xml Xml1...XmlN [--inplace] [-h] [-l] [-o]
├─┬╴get [-h]
│ ├─╴retrieve --alias Alias_1...Alias_N -p package.xml [--base-org OrgBaseDir] [-h]
│ ├─╴resList --alias Alias_1...Alias_N -t TYPE [--base-org OrgBaseDir] [-h]
│ ├─╴metaList --alias Alias_1...Alias_N [--base-org OrgBaseDir] [--ignore IGNORE] [-h]
│ ╰─╴report --alias Alias_1...Alias_N -j JOB_ID [--base-org OrgBaseDir] [-h]
├─┬╴cmp [-h]
│ ├─╴orgs --alias Alias_1...Alias_N [--base-org OrgBaseDir] [-f] [-h]
│ ╰─╴packages --xml Xml1...XmlN [-h]
╰─┬╴send [-h]
├─╴validate --alias Alias_1...Alias_N [--base-org OrgBaseDir] [--pack] [-h] [-t Min]
├─╴deploy --alias Alias_1...Alias_N [--base-org OrgBaseDir] [--pack] [-h] [-t Min]
├─╴runTest --alias Alias_1...Alias_N [--base-org OrgBaseDir] [--pack] [-h] [-t Min]
╰─╴quickDeploy --alias Alias_1...Alias_N [--base-org OrgBaseDir] [-h] [-t Min]
All parameters that require a path are defined in the final parsers. For example, the --base-org
parameter should accept a path as input, but the autocompletion isn’t working as expected.
Here’s what I’ve done so far:
1. Installed argcomplete
and enabled autocompletion in my script.
2. Used the activate-global-python-argcomplete
command to enable global autocompletion.
3. Checked my shell configuration and restarted the terminal.
Despite these steps, autocompletion suggests other optional parameters instead of paths. Has anyone else experienced this issue or knows how to resolve it?
I detect this problem boot in bash terminal and zsh terminal
Thanks in advance for any help!