Awesome
CBF 🦥
CBF 🦥is a simple CLI tool for developers who can't be f#@!'d learning or remembering all the commands they have to run day to day or just in a specific repo.
Developers build scripts that can either be saved directly to CBF or loaded on the fly from a local cbf.yml
file. The script will then serve as living, breathing runnable documentation for new starters, infrequent contributors or just developers who can't be f#@!'d learning or remembering all the commands.
Check out the wiki to get started!
Installation
npm i cbf -g
or
yarn global add cbf
Scripts
Simple scripts
CBF simple scripts can be stored as json
or yaml
files but must end with either .simple.json
or .simple.yml
so CBF knows to parse them differently than advanced scripts.
Simple scripts are made up of options and commands.
- The first tag is required and is the scripts name
- options are stored as keys
- commands are stored as values
Note: If you would like to customise directories
, messages
or variables
passed to each command
please use advanced scripts.
Example simple yaml script
hello:
world: "echo 'Hello, world!'"
mars: "echo 'Hello, mars!'"
jupiter: "echo 'Hello, jupiter!'"
Example simple json script
{
"hello": {
"world": "echo 'Hello, world!",
"mars": "echo 'Hello, mars!",
"jupiter": "echo 'Hello, jupiter!"
}
}
You can fine more example simple scripts here.
Advanced scripts
CBF advanced scripts can be stored as json
or yaml
files. Advanced scripts are made up of options
, command
, variables
, message
and directory
tags that are used to construct the layout of the script.
- The first tag is required and is the scripts name
options
tags are used to store lists of moreoptions
orcommand
'scommand
tags are used to store one or many strings containing shell commandsvariables
tags are used to prompt the user for variables to be replaced in a commandmessage
tags are used to store messages that are printed to stdout when an option or command is selecteddirectory
tags are used to set where a command should be ran. When a command is ran, CBF recursively searches for the commands set directory or closest set parentdirectory
tag
Example advanced yaml script
example-project:
message: 'Run, build or test example project?'
directory: '~/projects/example'
options:
run:
message: 'Running example project...'
command: 'yarn start'
build:
directory: '~/projects/example/src'
message: 'Building example project...'
command: 'yarn install'
test:
message: 'Run unit or integration tests?'
options:
unit:
message: 'Running example project unit tests'
command: 'yarn test:unit'
integration:
message: 'Running example project integration tests'
command: 'yarn test:integration'
Example advanced json script
{
"example-project": {
"message": "Run, build or test example project?",
"directory": "~/projects/example",
"options": {
"run": {
"message": "Running example project...",
"command": "yarn start"
},
"build": {
"directory": "~/projects/example/src",
"message": "Building example project...",
"command": "yarn install"
},
"test": {
"message": "Run unit or integration tests?",
"options": {
"unit": {
"message": "Running example project unit tests",
"command": "yarn test:unit"
},
"integration": {
"message": "Running example project integration tests",
"command": "yarn test:integration"
}
}
}
}
}
}
You can fine more example advanced scripts here.
Local CBF file
Commit a cbf.yml
to your repository so developers can run cbf
or cbf -d
to easily run and view commands related to the repository.
Package.json
Can't be f#@!'d writing a CBF script? Well guess what? You can just run cbf
or cbf -d
to easily run and view commands saved in the scripts
section of your repos package.json
file.
Note: If there is a local cbf.yml
file it will always instead of a package.json
file when just using cbf
or cbf -d
. However, you can manually choose to run the scripts
from a package.json
by running cbf -j
or cbf -dj
.
Additionally, you can filter out props by passing a comma separated list of property keys e.g.
cbf -j preinstall,postinstall
Usage
λ cbf -h
Usage: cbf [options]
cbf is a simple CLI tool for developers who can't be f#@!'d learning or remembering commands.
Go to https://github.com/joshuatvernon/cbf to learn how to make cbf scripts.
Options:
-V, --version output the version number
-D, --delete [script name] delete a previously saved script
-A, --delete-all delete all previously saved scripts
-d, --documented prepends the command to the questions when running a script
-R, --dry-run prints the command that would have been run to stdout
-j, --json [comma separated props] run scripts in a package json file
-l, --list list previously saved scripts
-N, --npm-alias set an alias that should be ran instead of npm when running scripts in a package json
-p, --print [script name] print a saved script
-r, --run [script name] run a previously saved script
-s, --save <path to script file> process and save a script from a yaml or json file
-S, --shell set which shell commands should be run within
-h, --help output usage information
Copyright
MIT