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

gluegunplus

v1.0.8

Published

GluegunPlus extends the capabilities of the original Gluegun Node.js module, empowering developers to create command-line interfaces with enhanced automation features.

Downloads

26

Readme

gluegunplus CLI

Gluegun Plus provides the first steps into developing language-agnostic and framework-agnostic CLIs. The CLI is built from a command API definition, which is currently given in a json file. There is also provided validation functions so that these do not have to be independently written in each command handler.

1. Features

  1. Inbuilt argument validation
  2. Command API definition

2. Supported Languages and Toolkits

| Language | Toolkit | Support | | -------- | ------- | ------- | | Node | Gluegun | ✔ | | Go | Cobra | ❌ |

3. Commands Structure

Example config.json

{
  "command1/c": {
    "description": "Command 1 Description",
    "__run": "command1Handler"
  },
  "command2/d": {
    "description": "Command 2 Description",
    "__run": { "func": "command2Handler", "args": { "a": true, "b": 4 } },
    "optional": {
      "a": "a argument supplied to command2Handler",
      "b": {
        "description": "b argument",
        "type": "int",
        "range": { "min": 1, "max": 10 },
        "default": 1
      }
    },
    "required": {
      "c": "A required arg"
    }
  },
  "command3": {
    "description": "Command 3 Description",
    "command4/d": {
      "description": "Command 4 Description",
      "__run": { "func": "command4Handler", "args": { "a": true, "b": 4 } },
      "optional": {
        "a": "a argument supplied to command4Handler",
        "b": {
          "description": "b argument",
          "type": "int",
          "range": { "min": 1, "max": 10 },
          "default": 1
        }
      },
      "required": {
        "c": "A required arg"
      }
    }
  }
}

The commands have a hierarchical structure. For example:

sample command1 
sample command2 
sample command3 command4

Each command/sub-command has the following sections: | Section | Description| |---------|------------| |command/alias| The command and the alias in the format cli rootcommand --subcommand1 --subcommandOfSubcommand1 ... --arg1 value. The commands and subcommands have an optional alias. They from the first part of the cli args supplied and they are supplied as args without a value. The command and the alias will do the same thing. Eg cli command1 is the same as cli c. Due to the hierarchical structure, arguments are processed in the order in which they are supplied. So that the following example will result in the execution of different functions: 1. cli c -c -d -c 1. and 2. cli c -d -e -c 1. The args after the root command arg are in order the subcommands in the hierarchy. The last subcommand has a "__run" object | |__run| This gives the name, an optionally the arguments, to be supplied to the function to be run for this command. The name can be given either as a string, or in an object in the format: {"description": "", "type": "", "range": {"min":1, "max":10}}| |description| String which gives the description of the command.| |optional| optional args to be supplied for the command. Supplied in either the format: { "arg": "description"} or {"arg:{"decription:"", {...type configuration}}}

Supported Arg Types

  • [x] int
  • [ ] float
  • [x] text
  • [ ] email
  • [ ] date
  • [ ] boolean

int

An int type can be configured with a range object which has optionally a min and max value.

text

A text type can be configured with a length object. The value for a length object is either an integer for a fixed length string, or an object with a min and max value.

4. Usage

You can either use the github repo as a template.

Or

Create a gluegun project using

npx gluegun new projectName
cd projectName
npm link

and run from projectName directory

npx gluegunplus init

This modifies the gluegun directory by creating

  1. root/config/commands.json with an sample commands file
  2. corresponding command files for each command specified in the json file.

// the file to run...

After writing the extension, you can create the files for the corresponding files using:

npx gluegunplus update

5. Fixes

Chalk

npm install [email protected]

6. License

See LICENSE