Skip to content

Short subcommand names #175

Description

@ALPSMAC

First off - decline is the most usable and sensible CLI parsing library in the Scala ecosystem I've encountered to date - so thanks for that! :-)

Summary:

It would be great if when parsing the library could match on a subcommand when enough letters are specified to uniquely identify the subcommand.

Example:

As a toy example, consider re-implementing bits of the kubectl cli:

lazy val get: Command[Observable[String]] = Command[String](
      name = "get",
      header = "Get resources from the k8s API"
    )(Opts.subcommands(
      get_pods,
      get_statefulsets,
      get_services,
      ...
    ))

It would be nice to trigger execution on get po or get st or get se instead of having to spell out the full resource each time.

Motivation:

For example, in the "real" kubectl, I can do something like kubectl get po rather than kubectl get pods. For CLIs that are complex and heavily used it's nice to be able to trim characters wherever possible. It's probably not part of the POSIX standard, but it certainly does improve quality-of-life for end users and seems prevalent enough in the different CLI tools I've encountered over the years.

Suggestion:

Could perhaps be implemented as an optional behavior - e.g.: Opts.subcommands(..., partialMatch = true)

Disclaimer:

I know Opts is implemented as an Alternative right now. I won't claim to have thought much about whether or not this parsing change would influence that... gut says probably not, but if the answer is "can't get there from here - algebra laws won't allow it" that's fine too.

Also - this could be related to #52 - may need similar matching logic in place (somewhere) for bash completion. Possible that the partial subcommand logic belongs there instead of as a built-in on the library itself... not sure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions