dotbot icon indicating copy to clipboard operation
dotbot copied to clipboard

feature-request: run a command IF a condition passes

Open Clumsy-Coder opened this issue 2 years ago • 3 comments

just like LINK directive, there should one for running individual commands for SHELL directive.

Ex:

- shell:
    - command: apt update && apt upgrade -y
      if: lsb_release -i | grep -io 'debian'
      description: Update APT package repository

    - command: dnf update -y
      if: lsb_release -i | grep -io 'fedora'
      description: Update DNF package repository

why

  • provides a better flow of running dotbot process
  • can contain similar commands in a single shell directive.
    • Ex: shell directive for updating repositories
    • Ex: installing a package using package manager in one OS, downloading a script from another OS

Clumsy-Coder avatar May 05 '22 03:05 Clumsy-Coder

This is already supported (without special syntax) by having the if be part of the command itself. E.g.

- shell:
    - command: "if (lsb_release -i | grep -io 'debian'); then apt update && apt upgrade -y; fi"
    - description: Update APT package repository

anishathalye avatar May 08 '22 18:05 anishathalye

True, you can do it that way.

I'm just hoping to keep the command and if condition separate

Clumsy-Coder avatar May 11 '22 16:05 Clumsy-Coder

@anishathalye I created a pull request implementing this feature. Have a look

Clumsy-Coder avatar Sep 06 '22 16:09 Clumsy-Coder