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

kawkah-parser

v1.0.8

Published

Simple CLI argument parser used by Kawkah.

Downloads

5

Readme

The argument parser for Kawkah. If you're looking for a full blow CLI parser you probably want Kawkah. You can think of kawkah-parser as sort of a normalizer before you would validate the parsed result against a schema then trigger perhaps an action. If you simply want to parse whatcha got and then handle constraints/coercion yourself kawkah-parser works great.

Install

$ npm install kawkah-parser

Usage

import { parse } from 'kawkah-parser';
const args = 'install /some/path names... tim sally joe --user.name bob --force --tags red --tags blue -abc -vvvvv --no-rename';
const result = parse();

Your result would be:

result = {
  _: ['install', '/some/path'],
  force: true,
  tags: ['red', 'blue'],
  names: ['jim', 'sally', 'joe'],
  user: { name: 'bob' },
  a: true,
  b: true,
  c: true,
  v: 5,
  rename: false,
  __: []
};

Options

For addtional option detail and API info see Docs below.

charVariadic

Character denoting variadic arguments.

const args = 'create blog java... c python javascript'
const result = parse(args);

Result would be:

result = {
  _: ['create', 'blog', ['java', 'c', 'python', 'javascript']],
};

charAbort

Character used to abort parsing of args.

const args = 'create blog -- ignore1 ignore2'
const result = parse(args);

Result would be:

result = {
  _: ['create', 'blog'],
  __: ['ignore1', 'ignore2']
};

charNegate

Character used to negate boolean flags.

const args = '--no-force'
const result = parse(args);

Result would be:

result = {
  force: false
};

allowParseBooleans

Allows parsing flags as boolean.

allowParseNumbers

Allows parsing number like values.

allowCamelcase

Allow converting some-flag to someFlag.

allowShortExpand

Allows expanding -abc to -a -b -c.

allowShortValues

Allows short flags to have values.

allowDuplicateOptions

Allows --tag red --tag green --tag blue which will be stored in an array.

allowDotNotation

Allows --user.name bob to result in { name: 'bob'}.

allowBoolNegation

Allows --no-force to set --force flag to false.

allowCountOptions

Allows -vvvvv to result in { v: 5 }.

allowVariadics

Allows arguments to be grouped in an array.

allowAnonymous

Allows anonymous arguments when false flags/args must have configuration.

allowExtendArgs

When true args in _ are extend to result object by name.

allowPlaceholderArgs

When true result._ args set as null when no value.

allowPlaceholderOptions

When true if a configured option is not present a placeholder is set.

onParserError

When null errors are thrown otherwise handled by specified handler.

Docs

See https://blujedis.github.io/kawkah-parser/

Change

See CHANGE.md

License

See LICENSE.md