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
👩
🎻 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.
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!
Just run the gluegun
CLI like this:
$ npm install -g gluegun-cli
$ 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
Let's start with what a gluegun
CLI looks like.
// in movie/src/cli.js...
// ready
const { build } = require('gluegun')
// aim
const movieCLI = build()
.brand('movie')
.configFile('./movie.toml')
.src(`${__dirname}/core-plugins`)
.plugins('node_modules', { matching: 'movie-*' })
.create()
// fire!
movieCLI.run()
Commands
// in movie/commands/foo.js
module.exports = async function (context) {
// gluegun provides all these features and more!
const { system, print, filesystem, strings } = context
// ...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 context 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!
- 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
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
⭐️ minimist, enquirer, colors, ora and ascii-table for the command line
⭐️ axios & apisauce for web & apis
⭐️ toml for human-friendly config files
⭐️ cross-spawn for running sub-commands
⭐️ execa for running more sub-commands
⭐️ node-which for finding executables
Node Node.js 7.6+ is required.
gluegun, as open source projects, is free to use and always will be. Infinite Red offers premium gluegun support and general mobile app design/development services. Email us at hello@infinite.red to get in touch with us for more details.