Socket
Socket
Sign inDemoInstall

@types/commander

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/commander

Stub TypeScript definitions entry for commander, which provides its own types definitions


Version published
Weekly downloads
163K
increased by5.34%
Maintainers
1
Weekly downloads
 
Created

What is @types/commander?

@types/commander provides TypeScript type definitions for the Commander.js library, which is a popular tool for building command-line interfaces (CLI) in Node.js applications.

What are @types/commander's main functionalities?

Command Definition

Defines a command named 'start' with a description and an action to be executed when the command is called.

const { Command } = require('commander');
const program = new Command();
program
  .command('start')
  .description('Start the application')
  .action(() => {
    console.log('Application started');
  });
program.parse(process.argv);

Option Parsing

Defines options for the command-line interface, including a boolean flag and a parameter with a default value.

const { Command } = require('commander');
const program = new Command();
program
  .option('-d, --debug', 'output extra debugging')
  .option('-p, --port <number>', 'port number', 3000);
program.parse(process.argv);
if (program.debug) console.log('Debugging enabled');
console.log(`Port: ${program.port}`);

Subcommands

Defines subcommands under a main command, allowing for more complex command structures.

const { Command } = require('commander');
const program = new Command();
const service = new Command('service');
service
  .command('start')
  .description('Start the service')
  .action(() => {
    console.log('Service started');
  });
service
  .command('stop')
  .description('Stop the service')
  .action(() => {
    console.log('Service stopped');
  });
program.addCommand(service);
program.parse(process.argv);

Other packages similar to @types/commander

FAQs

Package last updated on 03 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc