Uploaded image for project: 'Aesh'
  1. Aesh
  2. AESH-388

Command's state handling

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • 1.0.0.Alpha1, 0.66.9
    • None
    • None
    • None

    Description

      Today it is possible to share a private state between top level commands using Command constructor. For example:

      MySharedState state = ...;
      registry.register(New MyCommand1(state));
      registry.register(New MyCommand2(state));
      registry.register(New MyCommand3(state));

      This is not doable with sub commands. Sub command are created by Aesh Parser generator.

      The only way to do it is via CliCommandInvocation but this makes the private state public (and this is not wanted in my case).

      So I am suggesting to

      • Use the already existing GroupCommand interface (that extends Command interface). It defines the method List<Command> getCommands().
      • Change it to take a parameter.
      • Makes my top level command to implement it and returns the sub commands instances.
      • Make changes to the parser generator to check that the Command to parse is a GroupCommand and is annotated with GroupCommandDescription. If this is one, then call the getCommands method instead of creating them based on the Annotation content.

      This state can be today shared with OptionActivator because the ProcessedCommand is passed along the Activator. For command activator that is not doable. The CommandActivator needs to align with the OptionActivator.

      Attachments

        Activity

          People

            spederse@redhat.com Stale Pedersen
            jdenise@redhat.com Jean Francois Denise
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: