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

sergeant

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sergeant

A CLI solution with simple argument parsing and built in help messages.

  • 23.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

sergeant

A CLI solution with simple argument parsing and built in help messages.

Example

const command = require('sergeant')
const assert = require('assert')

command('hello', ({option, parameter, command}) => {
  parameter('name', {
    description: 'the name',
    required: true
  })

  option('loud', {
    description: 'say it loud',
    alias: 'l'
  })

  command('world', ({option}) => {
    option('loud', {
      description: 'say it loud',,
      alias: 'l'
    })

    return (args) => {
      say('world', args.loud)
    }
  })

  return (args) => {
    assert.notEqual(args.name, 'world', 'use hello world')

    say(args.name, args.loud)
  }
})(process.argv.slice(2))

function say (name, loud = false) {
  let message = `hello ${name}!`

  if (loud) {
    message = message.toUpperCase() + '!'
  }

  console.log(message)
}

Options and Parameters

These are the possible properties of options and parameters.

  • alias: Optional. A short alias for the option. (options only)
  • description: A short description
  • multiple: Optional. A boolean. If true then multiple values are accepted.
  • required: Optional. A boolean. If true it is required.
  • type: A function that should return the default if no value is given.

FAQs

Package last updated on 10 Dec 2018

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