npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

largs

v0.6.0

Published

A light weight command line args parser

Downloads

17

Readme

largs

Light weight args, command line parser

Simple cli arguments configuration and parsing with minimal dependencies.

The API has a similar feel to Yargs but largs has a limited feature set.

Requires Node 10+

Install

npm install largs --save

yarn add largs

Usage

Create an .option - ./script --option value -s short

or .positional - ./script one two

or a sub .command that supports all the same largs setup - ./command run --option value

and then .run() to process and return the options in a simple object

Options

Shortcut Options config setup

//import Largs from 'largs'
const { Largs } = require('largs')

const args = Largs.run({
  first: { short: 'f', required: true },
  second: { short: 's', long: 'two', type: 'integer', default: 1 },
  command_bork: {
    onlyhere: { type: String },
  }
})
console.log(args.bork.onlyhere) // => 'chef'

For functional setup

//import largs from 'largs'
const { largs } = require('largs')

largs.option('firstthing')
    .short('f')
    .required()

largs.option('otherthing')
    .short('s')
    .long('two')
    .type('integer')
    .default(1)

largs.command('bork')
    .option('onlyforbork')
        .type('string)

largs.positional('one')
    .type('enum', ['this'])
    .required()

const args = largs.run() // returns object representation of opts. `opts.largs`

console.log(args) // => { firstthing: "val", otherthing: "val", bork: { onlyforbork: 'yep' }, positional: [ 'one' ] }
→ node app.js --two 22222 this
Error: Missing required arguments
 "--firstthing/-f" is required

→ node app.js -f one --two 22222
Error: 1 argument is required

→ node app.js -f one --two 22222 asdf
Error: Arg "1" was "asdf" but must be one of: this"

→ node app.js -f one --two 22222 this
{ options: { first: 'one', second: 22222 },
  positional: [ 'this' ],
  config:
   { firstthing:
      { name: 'firstthing',
        short: 'f',
        long: 'firstthing',
        description: undefined,
        help: undefined,
        group: '' },
     otherthing:
      { name: 'otherthing',
        short: 's',
        long: 'two',
        description: undefined,
        help: undefined,
        group: '' } } }

API

About

largs is released under the MIT license.

Copyright 2019-2021 mhio

https://github.com/mhio/node-largs