Git Product home page Git Product logo

Comments (3)

lmorg avatar lmorg commented on June 13, 2024

What's happening with your code:

autocomplete set abc { [{
    "Dynamic": ( { -> %[ "xyz" ] } ),
    "Flags": [ "-foo" ],
    "FlagValues": {
        "-foo": [{
            "Flags": [ "bar" ]
        }]
    }
}] }

...is that xyz and -foo are both flags expected to be followed after the command.

The following code works as requested:

autocomplete set abc { [
    {
        "Flags": [ "-foo" ],
        "FlagValues": {
            "-foo": [{
                "Flags": [ "bar" ]
            }]
        },
        "optional": true
    },
    {
        "Dynamic": ( { -> %[ "xyz" ] } )
    }
] }

Where this differs is you're saying the first group is optional and -foo expects the value bar. The second group isn't optional and that returns the xyz value from your dynamic block.

from murex.

tiymat avatar tiymat commented on June 13, 2024

Thanks, that approach is working!

I've written a few autocompletions now and I thought I'd read the autocomplete builtin's documentation relatively thoroughly, but the concept of groups didn't really click for me until just now.

from murex.

lmorg avatar lmorg commented on June 13, 2024

Yeah, it's not really explained in the docs. The basic idea is the groups are to define position dependant parameters. While FlagValues define flag dependant parameters.

In your case you needed a mixture of two: flag dependant (for -foo) but also position dependant (xyz must follow any optional flags).

The gotcha with this is if xyz can come before or after -foo.

from murex.

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.