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

@clinjs/clargs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clinjs/clargs

Lightweight parser that helps building cli.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Clargs

Clargs is a simple light parser for building cli with node.js.

Installation

using npm npm i @clinjs/clargs

using yarn yarn add @clinjs/clargs

Setup

use clargs.setup() to configure your cli.

apitypedescriptionrequired
usageStringExplain how to use your cli.Yes
optionsoptionsDefine options the user can use.No
commandscommandsDefine the commands the user can use.No
clargs.setup({
  usage: 'commity <command> <options>',
  options: [
    {
      name: '--push',
      alias: '-p',
      description: 'push changes to current remote branch after commiting',
    },
    {
      name: '--addAll',
      alias: '-a',
      description: 'add all staged changes before commiting',
    },
  ],
  commands: [
    {
      name: 'init',
      description: 'inititialize Commity',
      options: [
        {
          name: '--overwrite',
          alias: '-o',
          description: 'overwrite existing config (if exist)',
        },
      ],
    },
  ],
});

Parse

Once you have setup clargs, you have to use clargs.parse() before accessing commands and options.

Commands

:pushpin: You have to use clargs.parse() Parse before clargs.hasCommand(command: string)

ApiReturn typeDescription
Function commandUsed(command: string)BooleanAllow you to know if a command is used.
const clargs = require('@clinjs/clargs');

clargs.setup({
  // ...
});
clargs.parse();
if (clargs.commandUsed('init')) {
  console.log('Command "init" used');
};

Help

Clargs includes help command that output cli usage, commands and options.

Options

:pushpin: You have to use clargs.parse() Parse before clargs.hasOption(option: string, alias: string)

ApiReturn typeDescription
Function hasOption(option: string, alias: string)BooleanAllow you to know if an option is used.
const clargs = require('@clinjs/clargs');

clargs.setup({
  // ...
});
clargs.parse();
if (clargs.hasOption('--foo', '-f',)) {
  console.log('--foo option passed');
}

Keywords

FAQs

Package last updated on 13 Apr 2021

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