Closed RagingPuppies closed 3 years ago
Thanks for the report. I believe this should work, since argcomplete should theoretically just invoke whatever name you give it; it shouldn't matter how the script is implemented. Can you try setting _ARC_DEBUG=1
and pasting the output of a completion attempt?
@evanunderscore sure Evan, here's the output for choices:
(root@bla-server:dist)# ./test --dest-dc
word --dest-dc split, lexer state: ' '
In trailing whitespace
LINE: './test --dest-dc '
POINT: 17
PREQUOTE: ''
PREFIX: ''
SUFFIX: ''
WORDS: []
Active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
Visited positionals: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
invoking parser with []
parsed args: (Namespace(dest_dc='', excluded=''), [])
all active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
active_parser: MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
optional options: ['-h', '--help', '--exclude-bla', '--dest-dc']
next_positional: None
Active actions (L=0): []
active options: ['-h', '--help', '--exclude-bla', '--dest-dc']
display completions: {('-h', '--help'): 'show this help message and exit', ('--exclude-bla',): 'space separated list of bla to ignore, will override included, ALL will include all bla', ('--dest-dc',): "'DC1','DC2','DC3'"}
Returning completions: ['-h', '--help', '--exclude-bla', '--dest-dc']
-
and heres output for the bla function
(root@bla-server:dist)# ./test --ex
word --ex split, lexer state: 'None'
LINE: './test --ex'
POINT: 11
PREQUOTE: ''
PREFIX: '--ex'
SUFFIX: ''
WORDS: []
Active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
Visited positionals: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
invoking parser with []
parsed args: (Namespace(dest_dc='', excluded=''), [])
all active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
active_parser: MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
optional options: ['--exclude-bla']
next_positional: None
Active actions (L=0): []
active options: ['--exclude-bla']
display completions: {(): "'DC1','DC2','DC3'", ('--exclude-bla',): 'space separated list of bla to ignore, will override included, ALL will include all bla'}
Returning completions: ['--exclude-bla']
clude-bla
word --exclude-bla split, lexer state: ' '
In trailing whitespace
LINE: './test --exclude-bla '
POINT: 21
PREQUOTE: ''
PREFIX: ''
SUFFIX: ''
WORDS: []
Active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
Visited positionals: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
invoking parser with []
parsed args: (Namespace(dest_dc='', excluded=''), [])
all active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
active_parser: MonkeyPatchedIntrospectiveArgumentParser(prog='test', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
optional options: ['-h', '--help', '--exclude-bla', '--dest-dc']
next_positional: None
Active actions (L=0): []
active options: ['-h', '--help', '--exclude-bla', '--dest-dc']
display completions: {('-h', '--help'): 'show this help message and exit', ('--exclude-bla',): 'space separated list of bla to ignore, will override included, ALL will include all bla', ('--dest-dc',): "'DC1','DC2','DC3'"}
Returning completions: ['-h', '--help', '--exclude-bla', '--dest-dc']
-
as you can see, it auto complete the arguments, but not the choices... let me know if there's anything i can do here.
For whatever reason, it's not parsing out the tokens (words) correctly.
LINE: './test --dest-dc '
POINT: 17
PREQUOTE: ''
PREFIX: ''
SUFFIX: ''
WORDS: []
Here's what it should look like:
LINE: './test --dest-dc '
POINT: 17
PREQUOTE: ''
PREFIX: ''
SUFFIX: ''
WORDS: ['./test', '--dest-dc']
This actually appears to be working fine for me with pyinstaller (at least on Windows):
LINE: './test.exe --dest-dc '
POINT: 21
PREQUOTE: ''
PREFIX: ''
SUFFIX: ''
WORDS: ['./test.exe', '--dest-dc']
The relevant code is here. I can't see how that would be going wrong, unless _ARGCOMPLETE
is somehow set to the wrong number. Your values of COMP_LINE and COMP_POINT appear correct, so something has to be going wrong in the linked section of code. You're welcome to do some debugging yourself, or if you can provide a complete set of instructions for how to replicate your build, I can try again to replicate your issue.
Hi Thanks @evanunderscore my issue was multiple duplicates bash scripts in the bash_completion folder, once cleaned it works :D thanks a lot!
No problem, glad you got it sorted!
Hi, once i compile my project to onefile executable with pyinstaller seems like only the arguments get autocompleted, no completers work, either from argparse "choices" nor from:
did anyone found a solution for this use-case? this is something supported? the # PYTHON_ARGCOMPLETE_OK was bypassed by providing the bash a filename instead of reading the string in the py file.
Thanks