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
The Command class is a fundamental building block in Climonad.js, representing an individual CLI command with associated flags, subcommands, and actions.
Constructor
Signature
Description
constructor(config: CommandConfig)
Initializes a new command with the specified configuration.
Properties
Property
Type
Description
name
string
The name of the command.
description
string
A brief description of the command's functionality.
alias
string | undefined
An optional shorthand name for the command.
required
boolean
Indicates whether this command is mandatory in the CLI context. Defaults to false.
flags
Flag[] | undefined
An array of flags associated with the command.
commands
Command[] | undefined
Subcommands nested under this command.
action
CommandAction | undefined
The function to execute when the command is invoked.
// Define a command with flags and a nested subcommandconststartCommand=cmd({name: "start",description: "Start the application",flags: [bool({name: "verbose",alias: "v",description: "Enable verbose output",}),str({name: "env",alias: "e",description: "Specify the environment",required: true,}),],action: async({ flags })=>{console.log("Starting application with environment:",flags.get("env"))},commands: [cmd({name: "server",description: "Start the server",action: async()=>{console.log("Server is starting...")},}),],})