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

yeow

v0.2.0

Published

CLI helper with attitude

Downloads

10

Readme

yeow

yeow is a CLI helper with attitude — part meow, part yargs, and built to spite the both of them.

things yeow does:

  • parse arguments
  • assert types
  • fail if given incorrect arguments

things yeow doesn't do:

  • negate arguments with --no-
  • interpret arguments as an array
  • restrict valid values to a predetermined list

install

$ npm i --save yeow

usage

#!/usr/bin/env node
const args = require("yeow")({
  "exclamation": {
    type: "string",
    required: true
  },
  "int": {
    type: "number",
    aliases: "--integer",
    default: 16
  }
});

console.log(args);
$ ./logger.js "yeow!"
{ exclamation: 'yeow!', int: 16 }

$ ./logger.js "cool!" --integer 100
{ exclamation: 'cool!', int: 100 }

API

yeow(obj)

returns an object of parsed arguments from the passed obj.

obj

type: object

each key is a human-readable argument name. the value is an object with any of:

type

type: string

type of the argument.

possible values:

  • string
  • number
  • file

if this is omitted, the argument will become a simple true/false flag.

required

type: boolean
default: false

whether the argument is required. required arguments ignore aliases and default.

the n-th argument for which required is set to true must be passed as the n-th argument to the program.

missing

type: string

error message to output if the argument is omitted.

if the argument is not required, this will be ignored.

aliases

type: string

valid aliases for the argument, space-slash-space separated.

example values:

  • -a
  • -a / --argument

if the argument is required, this will be ignored.

extensions

type: string

valid file extensions for the argument, space-slash-space separated.

example values:

  • .txt
  • .js / .jsx

if the argument's type is not file, this will be ignored.
if this is omitted, the argument will accept files of any extension.

default

type: string | number

a default value the argument will have if it is omitted. the value's type should match the argument's type.

if the argument is required, this will be ignored.

invalid

type: string

error message to output if the argument is passed with an invalid type.

example

const args = require("yeow")({
  "script": {
    type: "file",
    extensions: ".js",
    required: true,
    missing: "a file must be passed",
    invalid: "not a .js file"
  },
  "delay": {
    type: "number",
    aliases: "-d / --delay",
    default: 1
  },
  "input": {
    type: "string",
    aliases: "--input",
  },
  "verbose": {
    aliases: "-v / --verbose"
  }
});

donate

you can support the development of this project and others via Patreon:

Support me on Patreon