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

@codedungeon/gunner

v0.80.1

Published

Node CLI Framework

Downloads

233

Readme

Gunner

Description

NodeJS CLI Framework created in memory of my trusty sidekick "Gunner" who passed away in 2019, his memory will last in my heart forever.

Installation (Globally)

Use gunner globally to create new CLI projects (using gunner new...) or for creating new commands (gunner make:command xxx) and extensions (gunner make:extension xxx)

Using npm

> npm install -g @codedungeon/gunner

Using yarn

> yarn add global @codedungeon/gunner

Installation (Project)

When creating new CLI projects which use the gunner CLI engine, you can install gunner into your project as you would other npm modules

Using npm

> npm install @codedungeon/gunner

Using yarn

> yarn add @codedungeon/gunner

Using Gunner CLI

You can use the Gunner CLI to create new CLI projects

gunner new <project>

You will receive a series of prompts to guide you through the new project creation process

After new project has completed, you will see an installation summary similar to the following which will instruct what needs to happen next.

Change directory to new project to review your new CLI project scaffoled with the gunner starter.

Create new CLI command

Using the Gunner CLI, you can create new CLI commands as follows

gunner new:command test --name test

A new CLI command will be created in the src/commands directory

module.exports = {
  name: 'test',
  description: 'test description',
  disabled: false,
  hidden: false,
  usage: 'Do something cool, after all this is your command!',
  flags: {
    // example flag, adjust accordingly
    name: { aliases: ['n'], description: 'Command name', required: false },
  },
  execute(toolbox) {
    let name = toolbox.strings.titleCase(toolbox.arguments.name || 'world')
    toolbox.print.info(`Hello ${name}`)
  },
}

You can see your new CLI command in action by executing

hello test --name Mike

which will print the info

Hello Mike

Now, have a look at the CLI help

hello --help
🚧 hello v0.0.1 build 1
   Crafted with love by Mike Erickson ((https://github.com/mikeerickson))

Usage:
  hello info --limit 5

Commands:
  say-hello [args]              Say hello to my little friend!
  test [args]                   test description

Options:
  --help, -h, -H                Shows Help (this screen)
  --overwrite, -o               Overwrite Existing Files(s) if creating in command
  --quiet, -q                   Quiet mode (suppress console output)
  --version, -v, -V             Show Version
                                 (includes table of hello options)

Examples:
  hello info --versions 7,8

And, you can see command level help using the following example

hello test --help

Will output command help

🛠  test
   test description

Usage:
  Do something cool, after all this is your command!

Options:
  --name, -n              Command name

Adding Gunner CLI Engine to existing projects

In addition to creating new CLI projects discussed above, you can also add the Gunner CLI Engine to an existing Node based project by installing @codedungeon/gunner (see Installation above)

  • Create index.js file and add the following (showing the bare minimum required)
#!/usr/bin/env node

const { CLI } = require('@codedungeon/gunner')
const pkgInfo = require('./package.json')

const app = new CLI(process.argv, __dirname)
  .usage(`${pkgInfo.packageName} make:command TestCommand --name test:command`)
  .options(/* if not called, options will be suppressed in help dialog */)
  .version(/* version string override, if not supplied default version info will be displayed */)
  .examples(
    /* if not called, examples will be suppressed in help dialog */
    `${pkgInfo.packageName} make:command TestCommand --name hello`
  )
  .run()
  • Create new command in the src/commands directory (you can use the gunner new:command to quickly scaffold a new CLI command)
gunner make:command test --name test --description="test description"
  • Test you new CLI by executing node index.js from the root of your project
node index.js --help

Gunner API

Refer to docs/getting-started.md

Refer to docs/api.md

License

Copyright © 2019-2021 Mike Erickson Released under the MIT license

Credits

Gunner written by Mike Erickson

E-Mail: [email protected]

Twitter: @codedungeon

Website: codedungeon.io