Custom CLI commands for ultimate developer productivity
🗃️ Curate your own menu of command line workflows
🤖 Automate common tasks (project scaffolding, bulk ops, git flows)
⚡ Sync workflows across computers w/ GitHub
- GitHub workflows | Examples
- Project scaffolding | Examples
- Editing images | Examples
- Linux installs | Examples
- Guided tutorials | Examples
- See all
- Clone this template to a directory you plan to keep
degit MarshallCB/captain-example
- Write
[command-title].js
in the "commands" folder. Ex:commands/hello-world.js
This file must
export default
a generator function based on the API
// commands/hello-world.js
import captain from 'captain';
export default function*(){
yield "Hello World!";
let name = yield captain.text("What's your name?");
yield `Hello ${name}`;
}
- Name your captain to create a global CLI from this folder
In your package.json
{
"bin": {
"m4rsh": "./cli.js"
}
}
-
Run
npm link
to install dependencies and register the CLI with your computer -
Call
[captain-name] [command-title]
Based on previous steps:
m4rsh hello-world
> "Hello World!"
> "What's your name?"
> Marshall
> "Hello Marshall"
General format: yield captain[type](message, options, validation)
Type | Options |
---|---|
captain.text |
{ initial } |
captain.secret |
N/A |
captain.number |
{ initial, min, max, float } |
captain.date |
{ initial, locales, mask } |
captain.confirm |
{ initial } |
captain.toggle |
{ initial, active, inactive } |
captain.select |
{ initial, multi, hint, choices: { title, description, value, disabled } } |
captain.font |
{ colors, size } |
captain.shell |
{ dependencies } |
captain.progress |
{ promise } |
Coming soon
Generator Functions
Coming soon
Importance of Developer Experience
Coming soon
Security
Coming soon
Coming soon
- Thanks to @shinuza for the package name
- Generator section in JavaScript Glossary on Demand
MIT © Marshall Brandt