gluegun
A delightful toolkit for building Node-powered CLIs.
Last updated a month ago by infinitered-owner .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gluegun 
SYNC missed versions from official npm registry.

npm module CircleCI code style: prettier

Gluegun

gluegun

Gluegun is a delightful toolkit for building Node-based command-line interfaces (CLIs) in TypeScript or modern JavaScript, 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.

Why use Gluegun?

You might want to use Gluegun if:

  • You need to build a CLI app
  • You want to have powerful tools at your fingertips
  • And you don't want to give up flexibility at the same time

If so ... welcome!

Quick Start

Just run the gluegun CLI like this:

# spin up your new CLI
npx gluegun new movies

# choose TypeScript or Modern JavaScript
# now jump into the source
cd movies

# and link your new executable
yarn link

# and run it!
movies help

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

Code

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

// in movie/src/cli.[js|ts]...

// 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/src/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(await 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?

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.js 8.0+ is required. If you need to support Node 7.6, use Gluegun 3.x.

Community CLIs and Plugins

Here are a few community CLIs based on Gluegun plus some plugins you can use. Is yours missing? Send a PR to add it!

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 near Portland, Oregon. Our specialties are UI/UX design, React and React Native, Node, and more. Email hello@infinite.red if you'd like to talk about your project!

Current Tags

  • 4.1.2                                ...           latest (a month ago)
  • 4.0.1                                ...           next (2 months ago)

86 Versions

  • 4.1.2                                ...           a month ago
  • 4.1.1                                ...           a month ago
  • 4.1.0                                ...           2 months ago
  • 4.0.3                                ...           2 months ago
  • 4.0.2                                ...           2 months ago
  • 4.0.1                                ...           2 months ago
  • 4.0.0                                ...           3 months ago
  • 3.3.5                                ...           3 months ago
  • 3.3.4                                ...           4 months ago
  • 3.3.3                                ...           5 months ago
  • 3.3.2                                ...           5 months ago
  • 3.3.1                                ...           6 months ago
  • 3.3.0                                ...           7 months ago
  • 3.2.3                                ...           7 months ago
  • 3.2.2                                ...           7 months ago
  • 3.2.1                                ...           8 months ago
  • 3.2.0                                ...           9 months ago
  • 3.1.1                                ...           9 months ago
  • 3.1.0                                ...           9 months ago
  • 3.0.1                                ...           9 months ago
  • 3.0.0                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.7                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 0.22.1 [deprecated]           ...           a year ago
  • 2.0.0-beta.12                                ...           a year ago
  • 2.0.0-beta.11                                ...           2 years ago
  • 2.0.0-beta.10                                ...           2 years ago
  • 2.0.0-beta.9                                ...           2 years ago
  • 2.0.0-beta.8                                ...           2 years ago
  • 2.0.0-beta.7                                ...           2 years ago
  • 2.0.0-beta.4                                ...           2 years ago
  • 2.0.0-beta.3                                ...           2 years ago
  • 2.0.0-beta.2                                ...           2 years ago
  • 2.0.0-beta.1                                ...           2 years ago
  • 2.0.0-alpha.17                                ...           2 years ago
  • 2.0.0-alpha.16                                ...           2 years ago
  • 2.0.0-alpha.15                                ...           2 years ago
  • 2.0.0-alpha.14                                ...           2 years ago
  • 2.0.0-alpha.13                                ...           2 years ago
  • 2.0.0-alpha.12                                ...           2 years ago
  • 2.0.0-alpha.11                                ...           2 years ago
  • 2.0.0-alpha.8                                ...           2 years ago
  • 2.0.0-alpha.10                                ...           2 years ago
  • 2.0.0-alpha.9                                ...           2 years ago
  • 2.0.0-alpha.4                                ...           2 years ago
  • 2.0.0-alpha.3                                ...           2 years ago
  • 2.0.0-alpha.2                                ...           2 years ago
  • 2.0.0-alpha.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.22.0                                ...           2 years ago
  • 0.21.1                                ...           2 years ago
  • 0.21.0                                ...           2 years ago
  • 0.20.1                                ...           2 years ago
  • 0.20.0                                ...           2 years ago
  • 0.19.0                                ...           3 years ago
  • 0.18.2                                ...           3 years ago
  • 0.18.1                                ...           3 years ago
  • 0.18.0                                ...           3 years ago
  • 0.17.1                                ...           3 years ago
  • 0.17.0                                ...           3 years ago
  • 0.16.0                                ...           3 years ago
  • 0.15.0                                ...           3 years ago
  • 0.14.0                                ...           3 years ago
  • 0.13.0                                ...           3 years ago
  • 0.12.0                                ...           3 years ago
  • 0.11.0                                ...           3 years ago
  • 0.10.0                                ...           3 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.0                                ...           3 years ago
  • 0.7.3                                ...           3 years ago
  • 0.7.2                                ...           3 years ago
  • 0.7.1                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 4
This Week 4
This Month 72
Last Day 3
Last Week 33
Last Month 256
Dependencies (31)
Dependents (205)

Copyright 2014 - 2016 © taobao.org |