Skip to content

Main --help does not show command description: #28

@rubythulhu

Description

@rubythulhu

When I have a root command with sub-commands, as in:

import { CliCommand } from "cilly";
import { pkgUp as getPackageJson } from "pkg-up";
import { readFile } from "node:fs/promises";
import { URL } from "node:url";

const cmd1 = new CliCommand("hello")
  .withDescription("say hello")
  .withHandler(() => console.log("hey babe"));

const cmd2 = new CliCommand("goodbye")
  .withDescription("say goodbye")
  .withHandler(() => console.log("ttyl hun"));

const root = new CliCommand("mytool")
  .withVersion('1.2.3')
  .withDescription("My tool description")
  .withSubCommands(cmd1, cmd2)
  .withHandler(() => root.help());

await root.process(process.argv);

Expected Output:

Usage: mytool [options]

My tool description

Options:
  -h, --help         Display help for command
  -v, --version      Display the version

Commands:
  hello [options]    say hello
  goodbye [options]  say goodbye

Actual Output:

Usage: mytool [options]

My tool description

Options:
  -h, --help        Display help for command
  -v, --version     Display the version

Commands:
  hello [options]
  goodbye [options]

Why are descriptions of sub-commands not included in help output?

Is there any way I can fix this in my local project without re-implementing everything in the basic help output, but also providing this extra output? I just want the root command's --help to actually show what each subcommand does?

I do not wish to force the end user to run each and every [root-cmd] [sub-command] --help individually, collate this information into their own "how do i even use this tool" mycommand-cheat-sheet.txt, just to find out what each sub-command even does.

At present, it seems my only option is to completely override the help handler for the root command, individually re-implement all of the sections other than Commands:, then finally re-implement the Commands: section to provide this information. This seems like a hostile API interface though, so i am assuming i'm missing something?

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