Skip to content

Support multi-level nested command groups #127

Description

@dblevins

Summary

Add support for multi-level nested command groups so that a single @Command class can define commands at multiple depths in the command tree. Today, Crest supports one level of grouping (@Command("quote") on a class, @Command("create") on a method), but not deeper nesting like quote line-item add.

Motivation

CLI tools like az, gcloud, and kubectl use multi-level command groups extensively:

az storage blob upload
kubectl config set-context
gcloud compute instances create

In Crest-based CLIs, we currently flatten these into hyphenated names:

sforce quote add-line-item TT-00012345 ...

When we would prefer:

sforce quote line-item add TT-00012345 ...

Requirements

  • A command class should be able to have both direct subcommands and nested groups at the same level:

    quote create <args>          # direct subcommand
    quote line-item add <args>   # nested group
    quote line-item list <args>  # nested group
    quote line-item remove <id>  # nested group
    
  • This must be mix-and-match -- any node in the command tree can have both leaf commands and further sub-groups.

  • Help output should reflect the hierarchy, showing groups and commands at each level.

Possible Approach

One possible direction is allowing @Command on inner classes to define sub-groups:

@Command("quote")
public class QuoteCommand {

    @Command
    public void create(...) { }

    @Command
    public void delete(...) { }

    @Command("line-item")
    public class LineItemCommand {

        @Command
        public void add(...) { }

        @Command
        public void list(...) { }

        @Command
        public void remove(...) { }
    }
}

This is just one option -- the implementation design is open.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions