Red Shift

The official Infinite Red publication for React Native design & development. We’re a fully…

Follow publication

Announcing Gluegun 2.0 — A delightful way to build command line apps in Node

I’m pleased to announce the official release of Gluegun 2.0!

Gluegun — A delightful toolkit for building Node-powered CLIs

What is Gluegun?

Gluegun is a delightful toolkit for building beautiful command line interfaces (CLIs) in Node.js. It supports commands, extensions, template generation, and has a very simple and intuitive plugin interface. I’m the primary maintainer on Gluegun, and many others at my company (Infinite Red) and the community work on it too.

You can see the source code for this example movie CLI, powered by Gluegun, on Github

Gluegun is an alternative to Yeoman and Commander.js. We built Gluegun because we needed a CLI that was lighter than Yeoman, which tends to want to take over your entire workflow, yet more powerful than Commander, which doesn’t have first-class plugin support and is “bring your own tools”. We provide a built-in and world-class set of tools that covers many CLI use cases and yet is easily extended when you need additional capabilities.

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

The biggest app powered by Gluegun is the Amazon AWS Amplify CLI, which is a great code base to study to see how you can deploy a Gluegun CLI at scale. Our popular Ignite React Native starter kit is powered by an early version of Gluegun, while Solidarity (an environment checker for project dependencies across multiple machines) and several internal tools at Infinite Red are written with the latest Gluegun.

Gluegun is well-documented and we fix critical Github issues quickly.

What’s new in 2.0?

While the general idea of Gluegun remains, much of the internal code has been rewritten over the past six months. Here are the highlights:

  • TypeScript: Gluegun is now written in TypeScript and has first-class TypeScript support in addition to JavaScript!
  • Additional APIs: New CLI generator, semver parsing, a cool new file patching tool, CLI meta library, and too many others to list — see the API documentation to see what Gluegun now includes.

Key features of Gluegun

Easily spin up new CLIs with gluegun new mycli (Gluegun’s own CLI is powered by Gluegun, of course!) and access a great toolbox of commonly used CLI tools, including:

🌯 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

Additionally, you can write plugins for your CLI that will get seamlessly integrated by Gluegun. This lets you (or people in your community) extend your CLI in a very modular way. Check out the AWS Amplify CLI for an example of how to do this!

How to get started

Gluegun is super easy to get started. First, make sure you have Node installed. Then, run the following commands in your terminal:

$ npm install -g gluegun
$ gluegun new mycli --typescript
$ cd mycli && npm link
$ mycli --help
mycli version 0.0.1 mycli -
generate (g) -
help (h) -
version (v) Output the version number

Now you can start editing your new CLI!

Next steps:

Upgrading from previous betas or 0.22

Upgrading isn’t super difficult, but there are a few breaking changes. Rather than explaining it here, for the CLIs out there currently using Gluegun, just contact us on our Infinite Red Community Slack in the #gluegun channel and we’ll help you out.

Acknowledgements

Thanks to Gant Laborde for contributions and being an awesome Gluegun advocate to the community. Thanks to all the other contributors, whether providing testing, documentation, feedback, and code. Thank you to Steve Kellock for originally creating this great library while at Infinite Red. Thanks to Cindy Nguyen for the lovely graphic at the top of this blog post.

And lastly, thanks to Infinite Red, Inc. for sponsoring the development of Gluegun!

Jamon Holmgren is a co-founder and CTO at Infinite Red, an app and web design/development agency. Follow Jamon on Medium, Twitter, and Github for more Node/Gluegun, technology, and business talk. If you’re near Portland, Oregon, let’s have coffee!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Red Shift

The official Infinite Red publication for React Native design & development. We’re a fully distributed team building world-class apps for over 20 years for clients all around the world.

Written by Jamon Holmgren

Co-founder & CTO @infinite_red. Lutheran, husband, dad to 4, React Native Radio podcast host, Twitch streamer, hockey goalie. Talking shop!

No responses yet

Write a response