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

@qualityedgar/simple-flags

v2.1.0

Published

Simple and practical module to generate and organize command line flags and display usage

Downloads

3

Readme

Simple Flags

Modified version of https://github.com/PhilippeAssis/node-simple-flags. To have better help text and more options.

Installation

npm install --save @quality-edgar/simple-flags

Test

In node_modules/simple-args, run: npm run test

Features

option.name

Program Name. Shows in help text

option.description

Program Description. Shows in help text

option.helpHeader

Header for auto generated help.

option.synopsis

Synopsis auto generated help. An Array of strings containing sample commands.

option.flags

Flags to parse or generate help for.

Booleans

All Boolean object to be declared as an argument will have its inverted default value if true is false, is false is true.

You can create aliases for an object. When the value is not pre defined, use {objectName: ['a']}, passing the alias in an array. When the value is definiod use {alias: [ 'a', 'b'], default: "123"}

Description

To describe the flags, just add description. When you run --help the full description of the schema will be displayed

{
  print: {
    description: "Print all",
    default: true
  }
}

Print description's, --help

By default the --help flag is available when no other arument is passed before it.

myapp --help

You can force the display of the description of the flags using execute and calling within it the function this.help().

Execute

You can execute functions directly when a flag is declared. If the function has a return other than undefined the value will be set for the parameter.

const params = flags({ 
  flags : {
      print: {
        execute(){
          console.log(this.schema)
        }
      },
      support: {
        execute(){
          this.help() // print description's
        }
      },
      calc: {
        execute(){
          return 1 + 1 // params.calc === 2
        }
      }
  }
})

Example

Code

//test.js
var flags = require('simple-flags')

// Default options
var options = {
  'helpHeader' : "Usage Guide : \n",
  'args': ['author', 'website'],
  'name' : 'Program Name',
  'description' : 'Program Description',
  'synopsis' : ["prog --coffee --not","prog --developer='Sundeep Narang'"],
  'flags' : {
    'coffee': {
      default: false,
      description: 'You have coffee?'
    },
    'not': {
      default: true,
      description: 'Boolean example'
    },
    'developer': {
      aliases: ['dev', 'd'],
      description: 'Developer name'
    },
    'country': {
      aliases: ['c'],
      default: 'Do not be \'reaça\'',
      description: 'Your country'
    },
    'directFlag' : "test"
  }
}

console.log(flags(options))

Command

node test.js 'Quality EDGAR' ${HOME} --site www.qualityedgarsolutions.com --github=https://github.com/qualityedgar -d --coffee -not -c 'USA=QES'

Result

{ coffee: true,
  not: true,
  country: 'USA=QES',
  directFlag: 'test',
  site: 'www.qualityedgarsolutions.com',
  github: 'https://github.com/qualityedgar',
  author: 'Quality EDGAR',
  website: '/Users/sundeepnarang',
  developer: true }

Other Props

aliases

"country": {
    aliases: ['c', 'country']
}

default

"country": {
    default: "#foraTemer"
}

hidden

"hideFlagFromHelp": {
    hidden: true
}