Attila Doroszlai created HDDS-11878:
---------------------------------------

             Summary: Use CommandSpec to find top-level command
                 Key: HDDS-11878
                 URL: https://issues.apache.org/jira/browse/HDDS-11878
             Project: Apache Ozone
          Issue Type: Improvement
          Components: Ozone CLI
            Reporter: Attila Doroszlai
            Assignee: Attila Doroszlai


{{GenericParentCommand}} provides a way to access {{GenericCli}} methods from 
sub-subcommands.  However, its usage is tedious and comes with boilerplate code 
that needs to:

- implement {{GenericParentCommand}}
- define methods manually
- need member for {{@ParentCommand}} (injected by picocli)

Adding new methods to {{GenericParentCommand}} becomes harder the more 
implementations we have.

Example:

{code}
... implements GenericParentCommand {

  @ParentCommand
  private Shell shell;

  @Override
  public boolean isVerbose() {
    return shell.isVerbose();
  }

  @Override
  public OzoneConfiguration createOzoneConfiguration() {
    return shell.createOzoneConfiguration();
  }
{code}

This needs to be implemented on all sub-command levels.  Currently only very 
few implementations exists.

Some subcommands access top-level command via similar parent chain, but without 
implementing {{GenericParentCommand}}.

Picocli keeps track of the command hierarchy and allows accessing the top-level 
command directly via {{CommandSpec}}.  Therefore we can remove parent chains 
(with or without {{GenericParentCommand}}).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to