Skip to content

Proposal: Surface clearer help documentation around the default subcommand #143

@bdrelling

Description

@bdrelling

Commands with default subcommands do not have discoverable usage information without digging into the subcommand itself. Below, I'll outline the structure of a simple project as well as two proposals for updating the help information for commands that have a default subcommand.

Simply put, a command with a default subcommand likely doesn't have any information it runs itself and, as such, should specify the information that is available by running the default subcommand.

Structure

For ease of clarity, repeating the structure of my project here:

Command: zinc
Subcommands: lint, sync
Default Subcommand: sync

Proposal 1 - Highlighting the Default Subcommand

Problem Statement

The output of zinc --help is such that the default subcommand is not made clear.

This is what prints:

SUBCOMMANDS:
  lint                    Performs basic linting against a Zincfile to identify issues and errors.
  sync                    Syncs local files with remote files as defined by a Zincfile.

Proposed Solution

I'm proposing we highlight the default subcommand somehow:

SUBCOMMANDS:
  lint                    Performs basic linting against a Zincfile to identify issues and errors.
  sync                    (default) Syncs local files with remote files as defined by a Zincfile.

Proposal 2 - Prefer Default Subcommand Usage

Problem Statement

If I specify a default subcommand in my project, while I would allow someone to run zinc sync <args>, specifying a default subcommand likely implies that I'm happy with zinc <args>. As such, I think that the output of <command> --help should be refined.

Right now, here's what prints out when I run zinc --help:

OVERVIEW: Zinc is a command-line tool for keeping local files in sync with files hosted outside of your folder or
repository.

USAGE: zinc <subcommand>

OPTIONS:
  -h, --help              Show help information.

SUBCOMMANDS:
  lint                    Performs basic linting against a Zincfile to identify issues and errors.
  sync                    Syncs local files with remote files as defined by a Zincfile.

Here is the output of zinc sync --help:

OVERVIEW: Syncs local files with remote files as defined by a Zincfile.

USAGE: zinc sync [--file <file>] [--verbose]

OPTIONS:
  -f, --file <file>       The Zincfile to parse and use for syncing. (default: Zincfile)
  --verbose               Logs additional debug messages if enabled.
  -h, --help              Show help information.

Proposed Solution

I'm not sure what the right answer is here, but I imagine we should see an example of the default command being run, along with additional subcommands still.

I'm not sold on this, but here's an example:

OVERVIEW: Zinc is a command-line tool for keeping local files in sync with files hosted outside of your folder or
repository.

USAGE: 
  zinc --file <file>
  zinc <subcommand>

OPTIONS:
  -f, --file <file>       The Zincfile to parse and use for syncing. (default: Zincfile)
  --verbose               Logs additional debug messages if enabled.
  -h, --help              Show help information.

SUBCOMMANDS:
  lint                    Performs basic linting against a Zincfile to identify issues and errors.
  sync                    (default) Syncs local files with remote files as defined by a Zincfile.

Additional Notes

I'd like some additional feedback on the proposed solutions. I'm poking around at a variety of commands that I use day-to-day in my Swift projects as well as some outside of the Swift ecosystem and there's a variety of answers, but almost all at least provide some help documentation for a default subcommand within the help documentation of the command itself if requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions