Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sade

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sade

Smooth CLI operator

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7M
increased by4.62%
Maintainers
1
Weekly downloads
 
Created

What is sade?

The sade npm package is a lightweight command-line interface (CLI) library for building command-line applications in Node.js. It provides a simple and fluent API to define commands, options, and their associated actions. Sade allows developers to easily parse command-line arguments, manage sub-commands, and create user-friendly CLI tools.

What are sade's main functionalities?

Command Definition

This feature allows you to define a command with required and optional arguments. The 'describe' method is used to provide a description for the command, and the 'option' method is used to define options. The 'action' method is where the functionality for the command is implemented.

const sade = require('sade');

const prog = sade('mycli <input>').
  describe('Process the input file.').
  option('-o, --output', 'Specify output file').
  action((input, opts) => {
    console.log(`Processing ${input} with output ${opts.output}`);
  });

prog.parse(process.argv);

Sub-commands

This feature demonstrates how to define sub-commands within a CLI application. Each sub-command can have its own description and action handler.

const sade = require('sade');

const prog = sade('mycli').
  version('1.0.0');

prog.command('build').
  describe('Build the project.').
  action(() => {
    console.log('Building the project...');
  });

prog.command('deploy').
  describe('Deploy the project.').
  action(() => {
    console.log('Deploying the project...');
  });

prog.parse(process.argv);

Option Parsing

This feature shows how to parse options passed to the CLI. Options can be defined with a short and long version, and their presence can be checked within the action handler.

const sade = require('sade');

const prog = sade('mycli').
  option('-v, --verbose', 'Enable verbose output').
  action(opts => {
    if (opts.verbose) {
      console.log('Verbose mode is on.');
    }
  });

prog.parse(process.argv);

Other packages similar to sade

FAQs

Package last updated on 03 May 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