You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a suggestion to add an optional summary configuration field in command and subcommands which would be referenced when a short description is needed/preferable, like when listings choices of subcommands.
This would allow having both a concise description when a command or subcommand appears in a list in another command's help, and a long-form description with all the necessary details to keep in mind when using the CLI when viewing the command's help.
Example
consider the following example:
#!/bin/env node
// machine.tsimport{command,subcommands,binary}from"cmd-ts";constbrewCoffeeCmd=command({name: "brew coffee",description: // long description, maybe featuring notes or example usage`Brew a cup of coffee.Lorem ipsum dolor sit amet...`,summary: "Brew a cup of coffee",args: {/* args */},handler: ()=>{console.log("Brewing coffee...");},});constbrewCocoaCmd=command({name: "brew cocoa",description: // long description, maybe featuring notes or example usage`Brew a cup of hot cocoa.Lorem ipsum dolor sit amet...`,summary: "Brew a cup of hot cocoa",args: {/* args */},handler: ()=>{console.log("Brewing hot cocoa...");},});constbrewCmd=subcommands({name: "brew",description: // long description, maybe featuring notes or example usage`Brew a cup of a selection of hot drinks.Lorem ipsum dolor sit amet...`,summary: "Brew a hot drink",cmds: {coffee: brewCoffeeCmd,cocoa: brewCocoaCmd,},});constpayCmd=command({name: "pay",description: // long description, maybe featuring notes or example usage`Pay for a drink.Lorem ipsum dolor sit amet...`,summary: "Pay your drink",args: {/* args */},handler: ()=>{console.log("Payment complete, enjoy your drink!");},});constmachineCmd=subcommands({name: "machine",description: "coffee machine CLI utility",summary: "available but unused?",cmds: {brew: brewCmd,pay: payCmd,},});voidrun(binary(machineCmd),process.argv);
Which would generate the following help pages:
$> machine --help
machine <subcommand>
> coffee machine CLI utility
Where <subcommand> can be one of:
- brew - Brew a hot drink
- pay - Pay your drink
$> machine brew --help
brew <subcommand>
> Brew a cup of a selection of hot drinks.
Lorem ipsum dolor sit amet...
Where <subcommand> can be one of:
- coffee - Brew a cup of coffee
- cocoa - Brew a cup of hot cocoa
$> machine pay --help
pay
> Pay for a drink.
Lorem ipsum dolor sit amet...
and so on.
The text was updated successfully, but these errors were encountered:
This is a suggestion to add an optional
summary
configuration field incommand
andsubcommands
which would be referenced when a short description is needed/preferable, like when listings choices of subcommands.This would allow having both a concise description when a command or subcommand appears in a list in another command's help, and a long-form description with all the necessary details to keep in mind when using the CLI when viewing the command's help.
Example
consider the following example:
Which would generate the following help pages:
and so on.
The text was updated successfully, but these errors were encountered: