New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cli-cli-cli2

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-cli-cli2

Command line interface for node.js

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@kp/cli

Description

Command line interface for node.js

Installation

npm install @kp/cli

Usage

Command

import {Cli} from "@kp/cli";


const cli = new Cli();

cli.command("foo")
    .action(() => {
        return "Foo result";
    });

cli.run(process.argv).then((res) => {
    process.stdout.write(res);
}).catch((err) => {
    process.stderr.write(err.message);
});

Command argument

<bar> - required argument

[bar] - not required argument

cli.command("foo <bar1> [bar2]")
    .action((options, bar1: string, bar2?: string) => {
        return `Foo result, with arguments bar1=${bar1} bar2=${bar2}`;
    });

Command option

Types:

  • string
  • boolean
  • number
cli.command("foo")
    .option("bar", {
        type: "string",
        alias: "b"
    })
    .option("init", {
        type: "boolean",
        alias: "i"
    })
    .action((options) => {
        const {
            bar = "",
            init = false
        } = options;

        return `Foo result, with options bar=${bar} init=${init.toString()}`;
    });

Completion

cli.command("foo <bar>")
    .completion("bar", () => ["value1", "value2", "value3"])
    .action((options, bar: string) => {
        return `Foo result, with argument bar=${bar}`;
    });

cli.command("completion script")
    .action(() => {
        return cli.completionScript();
    });
source <(your-script.js completion script)

Keywords

FAQs

Package last updated on 12 Aug 2023

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