Closed naba-nyan closed 2 years ago
Thanks for the report. You're correct that arguments are not passed via the command line, only via the COMP_LINE environment variable. I'm not sure whether argcomplete could be updated to also pass arguments via the command line using e.g. COMP_WORDS. You could try altering the completion function and see what it does, e.g. removing the end of the slice here or adding the contents of COMP_WORDS here. However, it would probably need a lot of thought and testing before such a change could be merged back in.
Thanks for your interest in argcomplete. Please refer to this quote in the argcomplete documentation (https://github.com/kislyuk/argcomplete#argcompleteautocompleteparser):
argcomplete.autocomplete(parser) This method is the entry point to the module. It must be called after ArgumentParser construction is complete, but before the
ArgumentParser.parse_args()
method is called. The method looks for an environment variable that the completion hook shellcode sets, and if it's there, collects completions, prints them to the output stream (fd 8 by default), and exits. Otherwise, it returns to the caller immediately.
argcomplete does not support programs that call the parser.parse_args()
or parser.parse_known_args()
method before argcomplete.autocomplete(parser)
. argcomplete's behavior in such programs is undefined.
Hi, all contributors to
argcomplete
!In my test program (named testarc),
completions woks fine. However, in debug mode (_ARC_DEBUG), I notice that the arguments for this program is not passed to, then I have the following debug message:
argcomplete
. Indee, in my bash,testarc --dir mydir --foo
providestop_args = Namespace(dir='mydir'), remainging_args = [
--foo]
. However, attestarc --dir mydir
, I pushHere, I want the input arguments to be passed to
argcomplete
. For example, in my environment, the completion forparse.add_argument("--foo").completer = SomeClass(top_arg)
does not work fine sincetop_arg
isNamespace(dir=None)
inargcomplete
.Are there any solutions to this? Or if there are any mistakes, please report me!