Usage
Tauber's really simple, coming in at not even 200 lines of code. However, the possibilities are literally endless. It gives you a whole host of tools that you can use to build anything that you want.
#
cli.yamlTauber works with and within the cli.yaml
file. This file contains your CLI, is pure YAML, and is the backbone of how you use Tauber.
#
Defining commandsTo define a command, based on what you want that command to do, check the syntax below.
Your command executes a piece of Shell/Bash code
my command: echo "my bash code" # for multilinemy command: | cd mydir echo "my multiline bash code"
Your command executes a JavaScript (plain) file
my command: file: src/path/to/my/file.js
Your command executes a JS snippet
my command: code: console.log("hello") # for multilinemy command: code: | console.log("hello") console.log("world")
Your command executes multiple commands synchronously:
my command: actions: - my previous command - echo "something" - another previous command
#
Pre and PostThese are special commands that you can define, both defined the exact same way as any other command (refer the above instruction). These commands are special in how they are run.
pre
: this runs before every single command is called.post
: this runs after any command is called.
pre: echo "This is run before any commannd" post: code: | console.log("And this after")
#
Naming the filecli.yaml
is the file that Tauber looks for whenever you run Tauber. However, it's not the only valid name for the file that contains all your commands. While Tauber doesn't look for multiple files, it allows you to name the file whatever you want. There are different ways of specifying the name, which depends on your Tauber installation.
- If Tauber is installed globally: Whenever you run
tauber some command
, just add an argument--file filename
. Example:tauber hello world --file myfile.yaml
- If Tauber is installed locally: Simply change
"cli": "tauber"
to"cli": "tauber --file YOURFILENAME.yaml"
in thescripts
section of yourpackage.json
file.
Note: You don't have to use a .yaml
or .yml
extension for your file. You can use any extension (or no extension) and as long as your YAML is valid, Tauber will parse it. If you use VSCode, you can also specify YAML formatting by setting that as the file language in the bottom right.
#
Global vs Local InstallationTo help clarify the difference, I made this little chart that describes the difference between the two methods
Global Installation | Local Installation | |
---|---|---|
Installs tool... | Across the system | Only in the node_modules of the current directory |
Access point | Via the tauber command | Using npm run cli |
Needs package.json? | No, can be run anywhere | Yes |
Compatible with CI/CD? | No, requires npm i -g tauber | Yes, works with a simple npm i |
Usage in a complex project | Not recommended | Recommended |
Usage in a simple project | Only if there's no CI-CD | Recommended |
Standalone usage? | Yes | No |