EngineHub / Intake

IoC-oriented Java command parsing library
GNU Lesser General Public License v3.0
98 stars 21 forks source link

Let Bindings access CommandLocals #2

Closed TheE closed 9 years ago

TheE commented 9 years ago

As of writing, a Binding depends - as far as command handling is concerned - only on the string that is consumed by it. So unless there is some sort of randomization in the logic of the Binding itself, a certain string is guaranteed to result in the same object, regardless of who uses the command.

If a Binding could access the CommandLocals of the command it is currently parsing, more flexible implementations could be written since this guarantee no longer exists. Naturally this results in more complex code that is harder to validate - e.g. if a certain Binding implementation expects to be used with commands that are used by Players only, but is used on a command that can be used by the Console too - but I think if this behaviour is documented properly, it is up to the developer who wrote the complex Binding implementation to ensure that his code is working. Intake as a library should be as flexible as possible.

Are there any plans to let Bindings access CommandLocals? Or am I overlooking something here?

sk89q commented 9 years ago

I believe you can get an instance via context.getContext().getLocals().

TheE commented 9 years ago

Sorry I did not recognize this. Thanks four your fast answer.