8000 Completion with `python -m module_name` without creating an explicit executable script? · Issue #178 · iterative/shtab · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Completion with python -m module_name without creating an explicit executable script? #178
Closed as duplicate of#55
@rameloni

Description

@rameloni

I'm trying to enable auto-completion for Python scripts executed with python -m my_module -[TAB] [TAB] or python my_module.py -[TAB] [TAB].

I first created the script:

#!/usr/bin/env python3

import argparse

def get_main_parser():
    parser = argparse.ArgumentParser(prog="my_module")
    parser.add_argument("--a", default=None)
    parser.add_argument("--b", default=None)
    return parser


if __name__ == "__main__":
    parser = get_main_parser()
    args = parser.parse_args()
    print(args)

Then:

chmod +x ./my_module.py
alias my_module='./my_module.py'
eval "$(shtab --prog=my_module --shell=bash my_module.get_main_parser)"

And my_module -[TAB] [TAB] works but when I try python3 -m my_module -[TAB] [TAB] or python3 my_module.py -[TAB] [TAB] autocompletion doesn't work. I also tried to replace prog="my_module" with prog="my_module.py" but still it doesn't work.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0