-
-
Notifications
You must be signed in to change notification settings - Fork 1
How to write an advanced cbf script
Joshua Vernon edited this page Jan 3, 2020
·
2 revisions
Advanced scripts are made up of option's, command's, variables, message's and directory's
- The first tag is required and is the scripts name
-
options
tags are used to store lists of moreoptions
orcommand
's -
command
tags are used to store one or many strings containing shell commands -
variables
tags are used to prompt the user for variables to be replaced in a command -
message
tags are used to store messages that are printed to stdout when an option or command is selected -
directory
tags are used to set where a command should be run. When a command is run, CBF recursively searches for the commands set directory or closest set parentdirectory
tag
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-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 find more example advanced scripts here.
Save it to cbf
$ cbf -s example-project.json
Run it with cbf
$ cbf -r example-project
Thanks for using cbf
🦥