Conditional execution of Dotbot directives based on a shell command's exit status (success or failure). Inspired by dotbot-ifplatform.
This plugin requires Dotbot to be installed.
- Run
git submodule add https://github.com/wonderbeyond/dotbot-if.git
- Run
git submodule update --init --recursive
- Pass in the CLI argument
-p dotbot-if/if.py
when calling thedotbot
executable.
Add the if..cond..met..unmet
structure in the dotbot
YAML file
to conditionally execute any other directives. For examples:
You can omit any met
or unmet
part if you want do nothing at that state.
- if:
cond: 'python -V | grep -Eq "Python\s+3\."'
met:
- shell:
- echo Found Python 3.
unmet:
- shell:
- echo Python3 not found!
Can be the switch/match..case
equivalent.
- if:
- cond: 'command -v apt-get'
met:
- apt:
- jq
- cond: 'command -v brew'
met:
- brew:
- jq