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.

  • 20.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', function ({option, parameter, command}) {
  parameter('name', {
    description: 'the name',
    required: true
  })

  option('loud', {
    description: 'say it loud',
    aliases: ['l']
  })

  command('world', function ({option}) {
    option('loud', {
      description: 'say it loud',,
      aliases: ['l']
    })

    return function (args) {
      args.name = 'world'

      say(args)
    }
  })

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

    say(args)
  }
})(process.argv.slice(2))

function say (args) {
  let message = `hello ${args.name}!`

  if (args.loud) {
    message = message.toUpperCase()
  }

  console.log(message)
}

API Reference

command

command(name, description, define)

  • name: A string. The name of your command
  • description: A string. A short description. Optional
  • define: A function to define your command

define

define({[option, parameter, command})

It should return a function to call when the command is run. See action

option

option(key, definition)

  • key: The name of the option
  • definition: An object that defines your option

parameter

parameter(key, definition)

  • key: The name of the parameter
  • definition: An object that defines your parameter

action

action(args)

It's passed args which are all the options and parameters when run.

definition

{aliases, description, multiple, required, type}

  • aliases: Optional. An array of strings, each an alias.
  • 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 16 Jun 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