simon-bueler / dotbot-if

Conditional execution of dotbot directives.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dotbot if Plugin

Conditional execution of Dotbot directives based on a shell command's exit status (success or failure). Inspired by dotbot-ifplatform.

Prerequisites

This plugin requires Dotbot to be installed.

Installation

  1. Run git submodule add https://github.com/wonderbeyond/dotbot-if.git
  2. Run git submodule update --init --recursive
  3. Pass in the CLI argument -p dotbot-if/if.py when calling the dotbot executable.

Usage

Add the if..cond..met..unmet structure in the dotbot YAML file to conditionally execute any other directives. For examples:

The if..else equivalent

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!

Multiple parameter groups for single if

Can be the switch/match..case equivalent.

- if:
  - cond: 'command -v apt-get'
    met:
    - apt:
      - jq
  - cond: 'command -v brew'
    met:
    - brew:
      - jq

About

Conditional execution of dotbot directives.

License:MIT License


Languages

Language:Python 100.0%