Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A delightful toolkit for building TypeScript-powered command-line apps.

License

NotificationsYou must be signed in to change notification settings

infinitered/gluegun

Repository files navigation

npm moduleCircleCIcode 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
📦packageManager - installing NPM packages with Yarn or NPM

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

Notice

Gluegun is at a stable point and we aren't planning on building new features for it, although the community continues to send in PRs and we release them if they are performance, stability, types, or other similar enhancements. Read theCommunity Supported section to learn more.

Why use Gluegun?

Introductory YouTube video by our CTO, Jamon Holmgren:https://www.youtube.com/watch?v=_KEqXfLOSQY

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 thegluegun CLI like this:

# spin up your new CLInpx gluegun new movies# choose TypeScript or Modern JavaScript# now jump into the sourcecd movies# and link your new executableyarn 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 agluegun CLI looks like.

// in movie/src/cli.[js|ts]...// readyconst{ build}=require('gluegun')// aimconstmovieCLI=build('movie').src(`${__dirname}/src`).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.jsmodule.exports={name:'foo',alias:'f',run:asyncfunction(toolbox){// gluegun provides all these features and more!const{ system, print, filesystem, strings}=toolbox// ...and be the CLI you wish to see in the worldconstawesome=strings.trim(awaitsystem.run('whoami'))constmoreAwesome=strings.kebabCase(`${awesome} and a keyboard`)constcontents=`🚨 Warning!${moreAwesome} coming thru! 🚨`consthome=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 thetoolbox api docs for more details on what you can do.

See theruntime 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?

Additionally, the first versions of theAWS Amplify CLI (a CLI toolchain for simplifying serverless web and mobile development) used Gluegun. They've since integrated Gluegun's functionality into their CLI in a bespoke way, but you can still see Gluegun patterns in their CLI.

What's under the hood?

We've assembled anall-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 andcli-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 12.0+ is required.

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!

Community Supported

While Gluegun is no longer actively developed byInfinite Red, it has built a community that cares deeply about it. Infinite Red won't be building new features ourselves for Gluegun, but we encourage the community to continue to send high quality pull requests. We will try to review and merge them in a timely manner.

If you're looking for alternatives, here's a list:

  • Rust CLI -- Rust is a rapidly growing community and hot language, and has the benefit of speed and not needing to rely on a local Node engine.
  • oclif - oclif is used by some large CLIs and is very actively maintained
  • commander andyeoman - commander and yeoman have been around a long time and have very large communities. Keep in mind that we built Gluegun to avoid Commander and Yeoman, so YMMV
  • vorpal - unfortunately looks like it isn't actively maintained
  • just make your own - you don't need a framework to make a Node CLI. Check out this article from Twilio

And of course, check out your favoriteReact Native Consultants, Infinite Red!.


[8]ページ先頭

©2009-2025 Movatter.jp