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

oopt

v1.0.2

Published

Old good getopt with no extras

Downloads

19

Readme

Oopt

Parsing commanl-line arguments in style of old good getopt with no extras. For geeks and minimalists only. Only configuration is standart optstring (something like 'ab:c') and result is an object with 'options', 'arguments' and 'operands'.

Build Status NPM version

If no bugs, it ought to be pure getopt, that is described in The Open Group Base Specifications Issue 7 (aka IEEE Std 1003.1, 2013 Edition):

The getopt() function is a command-line parser that shall follow Utility Syntax Guidelines 3, 4, 5, 6, 7, 9, and 10 in XBD Utility Syntax Guidelines.

Main intention was to make utility, which passed tests, that describe those XBD Utility Syntax Guidelines:

Guideline 3: Each option name should be a single alphanumeric character (the alnum character classification) from the portable character set. The -W (capital-W) option shall be reserved for vendor options. Multi-digit options should not be allowed.

Guideline 4: All options should be preceded by the '-' delimiter character.

Guideline 5: One or more options without option-arguments, followed by at most one option that takes an option-argument, should be accepted when grouped behind one '-' delimiter.

Guideline 6: Each option and option-argument should be a separate argument, except as noted in Utility Argument Syntax, item (2).

Guideline 7: Option-arguments should not be optional.

Guideline 9: All options should precede operands on the command line.

Guideline 10: The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.

If something in oopt works not like in Guidelines - that's a bug. Feel free to make issue or pull request.

Install

npm install oopt

Tests

$ npm test

Example

//app.js
var oopt = require('oopt');
console.log(oopt('ab:c'));

$ node app.js
{ a: false, b: '', c: false}
$ node app.js -a -b arg
{ a: true, b: 'arg', c: false }
$ node app.js --
{ a: false, b: '', c: false, _: [] }
$ node app.js -ab arg p1 p2
{ a: true, b: 'arg', c: false, _: [ 'p1', 'p2' ] }
$ node app.js -a -b arg p1 p2
{ a: true, b: 'arg', c: false, _: [ 'p1', 'p2' ] }
$ node app.js -b arg -a p1 p2
{ a: true, b: 'arg', c: false, _: [ 'p1', 'p2' ] }
$ node app.js -a -barg p1 p2
{ a: true, b: 'arg', c: false, _: [ 'p1', 'p2' ] }
$ node app.js -abarg p1 p2
{ a: true, b: 'arg', c: false, _: [ 'p1', 'p2' ] }
$ node app.js -a -b arg -- -c p1 -p2
{ a: true, b: 'arg', c: false, _: [ '-c', 'p1', '-p2' ] }
$ node app.js -a -b "a r g" "p1 p2"
{ a: true, b: 'a r g', c: false, _: [ 'p1 p2' ] }
$ node app.js -b -a
{ a: false, b: '-a', c: false }
$ node app.js "-a -b"
{ a: false, b: '', c: false, _: [ '-a -b' ] }
$ node app.js p1 p2 -a -b arg
{ a: false, b: '', c: false, _: [ 'p1', 'p2', '-a', '-b', 'arg' ] }

More examples in tests.

License

MIT