Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature-request: run a command IF a condition passes #312

Open
Clumsy-Coder opened this issue May 5, 2022 · 3 comments
Open

feature-request: run a command IF a condition passes #312

Clumsy-Coder opened this issue May 5, 2022 · 3 comments

Comments

@Clumsy-Coder
Copy link

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 Clumsy-Coder changed the title feature-request: run a command **IF** a condition passes feature-request: run a command IF a condition passes May 5, 2022
@anishathalye
Copy link
Owner

anishathalye commented May 8, 2022

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

@Clumsy-Coder
Copy link
Author

Clumsy-Coder commented May 11, 2022

True, you can do it that way.

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

@Clumsy-Coder
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants