Command addon with choice prompt?


#1

I’m on a plugin that works along the lines of this:


class Example:

    def __init__(self):
        self.things = []

    def request(self, flow):
        self.things.append("thing i captured from request")
    
    @command.command('thing.options')
    def options(self) -> typing.Sequence[str]:
        return self.things # all the things i've capture

    @command.command('thing.apply')
    @command.argument('choice', type=types.Choice('thing.change'))
    def make_change(self, flow: flow.Flow, choice: str) -> None:
        # apply the chosen thing to intercepted flow
        pass

I’d like it to use it with popup a choice view in a similar way to how console.bodyview or console.edit.focus but can’t seem to figure out how to get it to work. Do I need to specify key mappings somewhere or could I auto-invoke console.choose somehow?

Thanks for any help in advance!


#2

Found out that this works:

ctx.master.commands.call('console.choose.cmd "Pick a thing" thing.options thing.apply {choice}')

However I can only seem to get it to work as below rather than invoking thing.apply directly anyway…

ctx.master.commands.call('console.choose.cmd "Pick a thing" thing.options console.command thing.apply {choice}')

Any other suggestions welcome.