A delightful toolkit for building Node-powered CLIs.
TypeScript HTML JavaScript
Latest commit 5cd228e Jun 11, 2018
Permalink
Failed to load latest commit information.
bin WIP: Disable core extensions for performance reasons Feb 21, 2018
docs Minor changes to release documentation Apr 17, 2018
github Fix labels.json file Nov 24, 2017
models ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
src chore: migrate to cli-table3 Jun 11, 2018
.editorconfig Adds an initial structure. Nov 29, 2016
.gitattributes Adds an initial structure. Nov 29, 2016
.gitignore Remove lockfile May 10, 2018
.prettierignore Adds home page for docs Feb 5, 2018
LICENSE Remove extra files, add package.json Oct 26, 2017
filesystem.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
http.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
jest-integration.config.json 🤡 Converts from Ava to Jest tests Mar 18, 2018
package.json chore: migrate to cli-table3 Jun 11, 2018
patching.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
print.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
prompt.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
readme.md chore: migrate to cli-table3 Jun 11, 2018
semver.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
sniff-async.js 🏗 TypeScript, Rollup, and Friends! 🔨 Jan 4, 2018
sniff.js 🏗 TypeScript, Rollup, and Friends! 🔨 Jan 4, 2018
strings.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
system.js ☝️ Adds direct access to tools from Gluegun Apr 15, 2018
toolbox.js 👨🏻‍💻 Toolbox available from require(gluegun) directly Mar 18, 2018
tsconfig.json 👗 Makes the build output prettier Mar 18, 2018
tslint.json Adds package files to prettierignore Jan 11, 2018

readme.md

npm module All Contributors Build Status Coverage Status code style: prettier Chat about GlueGun in the IR Community

gluegun

gluegun is a lightweight toolkit for building command-line interfaces (CLIs), with support for:

🌯 parameters - command line arguments and options
🎛 template - generating files from templates
🗄 patching - manipulating file contents
💾 filesystem - moving files and directories around
system - executing other command-line scripts
🎅 http - interacting with API servers
🛎 prompt - auto-complete prompts
💃 print - printing pretty colors and tables
👩‍✈️ semver - working with semantic versioning
🎻 strings - manipulating strings & template data

In addition, gluegun supports expanding your CLI's ecosystem with a robust set of easy-to-write plugins and extensions.

Yeah, But Why?

If you want to have your CLI...

  • get built quickly
  • have plugin support
  • but skip the boring parts of developing it
  • and avoid large CLI libraries that want to take over your world

... welcome!

Quick Start

Just run the gluegun CLI like this:

$ npm install -g gluegun@next
$ gluegun new movies
$ cd movies
$ npm install
$ npm link
$ movies help

You should see your new CLI help. Open the folder in your favorite editor and start building your CLI!

Tip: If you want your CLI to use TypeScript, pass in --typescript

Code

Let's start with what a gluegun CLI looks like.

// in movie/src/cli.js...

// ready
const { build } = require('gluegun')

// aim
const movieCLI = build('movie')
  .src(`${__dirname}/core-plugins`)
  .plugins('node_modules', { matching: 'movie-*' })
  .help()
  .version()
  .defaultCommand()
  .create()

// fire!
movieCLI.run()

Commands

Commands are simple objects that provide a name, optional aliases, and a function to run.

// in movie/commands/foo.js
module.exports = {
  name: 'foo',
  alias: 'f',
  run: async function(toolbox) {
    // gluegun provides all these features and more!
    const { system, print, filesystem, strings } = toolbox

    // ...and be the CLI you wish to see in the world
    const awesome = strings.trim(system.run('whoami'))
    const moreAwesome = strings.kebabCase(`${awesome} and a keyboard`)
    const contents = `🚨 Warning! ${moreAwesome} coming thru! 🚨`
    const home = process.env['HOME']
    filesystem.write(`${home}/realtalk.json`, { contents })

    print.info(`${print.checkmark} Citius`)
    print.warning(`${print.checkmark} Altius`)
    print.success(`${print.checkmark} Fortius`)
  }
}

See the toolbox api docs for more details on what you can do.

See the runtime docs for more details on building your own CLI and join us in the #gluegun channel of the Infinite Red Community Slack (community.infinite.red) to get friendly help!

Who Is Using This?

  • Ignite - React Native Starter Kit
  • Solidarity - audits your system dependencies so you can develop in peace
  • AppMachine - closed source for now (still building) - tool for helping code generate apps

What's under the hood?

We've assembled an all star cast of libraries to help you build your CLI.

⭐️ ejs for templating
⭐️ semver for version investigations
⭐️ fs-jetpack for the filesystem
⭐️ yargs-parser, enquirer, colors, ora and cli-table3 for the command line
⭐️ axios & apisauce for web & apis
⭐️ cosmiconfig for flexible configuration
⭐️ cross-spawn for running sub-commands
⭐️ execa for running more sub-commands
⭐️ node-which for finding executables
⭐️ pluralize for manipulating strings

Node Node.js 7.6+ is required.

Sponsors

Gluegun is sponsored by Infinite Red, a premium custom mobile app and web design and development agency. We are a team of designers and developers distributed across the USA and based out of Portland, Oregon and the San Francisco Bay Area. Our specialties are UI/UX design, React Native, React, and Elixir. Email hello@infinite.red if you'd like to talk about your project!