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

kumander

v0.0.4

Published

Simple, Express-style CLI framework for Node

Downloads

4

Readme

Kumander (Alpha)

Simple, Express-style CLI framework for Node. Create CLI programs written in Typescript or in Javascript with no additional dependencies.

Install

NPM

$ npm install --save [email protected]

Yarn

$ yarn add [email protected]

Usage

  • Import first the module
// For Typescript
import { CLI } from "kumander/dist/kumander";
const cli = CLI();

// For NodeJS
const kumander = require("kumander/dist/kumander");
const cli = kumander.CLI();
  • Start using it by adding commands and options.
cli.set("name", "My CLI app"); // Add CLI name
cli.set("version", "1.0"); // Add CLI version
cli.set("description", "Just a normal command line program"); // CLI description
cli.set("defaultCommand", "print"); // Add default command to be executed

// Adds "yolo" option
cli.option("yolo", () => {
    console.log("You only live once.");
}, {
    description: "Prints the meaning of YOLO.",
    asCommand: true // treats the option as a command.
})

// Adds "name" option
cli.option("age", (value) => {
    return value;
}, {
    description: "Age option", // Describe the name option
    shorthand: "A" // Shortcut for the option ("-A")
});

cli.command("print", ({ options, _args }) => {
    console.log(`Hello my name is ${_args[0]}`);
    if (options.age) {
        console.log(`I'm ${options.age} years old.`)
    }
}, {
    arguments: 1, // Defines how many arguments to be used.
    description: "Prints a name" // Describe the command
});

cli.run(process.argv.slice(2)); // Runs the CLI with the ARGV array;
  • Run the program
$ node test.js print Joe --age=20
Hello my name is Joe
I\'m 20 years old.

$ node test.js --yolo
You only live once.

Adding additional info

// You must insert them first before you add the commands/options.

cli.set("name", "My CLI app"); // Add CLI name
cli.set("version", "1.0"); // Add CLI version
cli.set("description", "Just a normal command line program"); // CLI description
cli.set("defaultCommand", "print"); // Add default command to be executed

--help Generation

Kumander can auto-generate the list everytime you add a command or option.

$ node test.js --help
My CLI app
Just a normal command line program

Usage: my_cli app [options]

Options:

--version                     Displays CLI version
--yolo                        Prints the meaning of YOLO.
--help                        Displays the list of commands and options
--age                         Age option
-A                            Shortcut of 'age'
-v                            Shortcut of 'version'
-h                            Shortcut of 'help'

Commands:

print                         Prints a name

Development

Build

Kumander is written on Typescript from the ground-up and must install the tsc compiler first before you start building this module. After that, you can start building it by executing:

$ npm build-dev

Roadmap

  • [x] Command argument support
  • [x] Shorthand option support
  • [ ] Middleware / Plugin Support(?)
  • [x] JSDoc comments
  • [x] --help generation
  • [ ] Error handling
  • [ ] Tests

Contribute

  1. Fork / Clone this repo. (git clone https://github.com/nedpals/kumander.git)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Copyright

  • © 2018 Ned Palacios (nedpals)