I am trying to work with `obj` in a set of chainab...
# clikt
p
I am trying to work with
obj
in a set of chainable sub-commands. My outer most CliktCommmand should set
obj
directly, but sub-commands may want to replace this instance. I want to maintain the sub-command separation though, so any sub-command should not need to know which parent context the actual object is set in. Given this, I cannot use
currentContext.obj
to set the new instance in a sub-command, that future CliktCommands in the chain can access. This is natural, as it will set it on the sub-commands context, not a parents. I also cannot use
findOrSetObject
on
currentContext
as this will correctly identify that the current instance in the correct parent context But it is going to find one set in a parent, so will return the current value, ignoring the block provided. There is no replacement logic, a
currentContext.findAndSetObject
if you will. Is there a simple way to implement such replacement logic?