Giter Club home page Giter Club logo

Comments (8)

kislyuk avatar kislyuk commented on July 18, 2024

You probably should. I think this is a consequence of how I currently find the active action (the action that the parser was on when it finished or crashed). Since your argument has nargs="*", it accepts 0 words and the parser moves on to the next action. Instead of having just one active action, I should probably build a mapping of actions to words that those actions were activated on, and consider all the actions that were activated on the last word to be active (so, grab all of their completions).

from argcomplete.

kislyuk avatar kislyuk commented on July 18, 2024

I think this will help: 938ec6a but this really needs more testing (particularly I need to write test cases). Let me know if it works for you.

from argcomplete.

lphoward avatar lphoward commented on July 18, 2024

It does indeed. Thanks!

from argcomplete.

lphoward avatar lphoward commented on July 18, 2024

Spoke a bit too soon. I get autocompletion for the first occurrence of the argument with nargs="*", but none thereafter for this argument.

In my testing using your commit, I also do not get completion on a second occurrence of an optional argument with nargs="+" with a ChoicesCompleter.

You might also want to consider optional arguments with nargs="+" in combination with a positional with nargs="*". In these cases, there are two ways to deal with the multiplicity:

$ command verb positional_A positional_B --optional option_A option_B

That is, to put the optional argument at the end, or using the pseudo argument "--":

$ command verb --optional option_A option_B -- positional_A positional_B

Thanks again for looking into this!

from argcomplete.

kislyuk avatar kislyuk commented on July 18, 2024

Does this help? 0279e77 (it's in master)

(Regarding the second part, I get that for free by piggybacking on the parse process. All I need to do is make sure that I have all the actions which could have possibly eaten the next word on the command line.)

from argcomplete.

lphoward avatar lphoward commented on July 18, 2024

That seems to have got it. Thanks!

from argcomplete.

kislyuk avatar kislyuk commented on July 18, 2024

Cool, thanks for reporting. Gonna keep this open until I get around to adding tests for it.

from argcomplete.

nickl- avatar nickl- commented on July 18, 2024

Works for aero too...

from argcomplete.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.