anishathalye / anishathalye/dotbot

Allow `if` on tasks

Aperta
#225 6 commenti 3 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
8k
Fork
320
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I have an enhancement to propose: Allowing an `if` property (which would work just like the `link` option) on the top-level tasks, alongside each directive. If the executed command is not successful, the whole task would be skipped.

The idea is that you could define sets of `link`s, or `shell` commands, or whatever task, for an environment/profile/whatever. My use case is that I'd like to have a task with `link`s that are always created, and then another set just for personal machines, and a third just for work machines. I have a different `.gitconfig` file between the two, plus a `.pairs` file for work, plus more...Since I can't put two different entries for the same file under a single `link` task, I need to have different task for these cases, anyway. So, it would be wonderful if I didn't have to repeat the same `if` option again and again and again.

For exmaple:

```
- link:
# all my common links

- if: [[ ! $PROFILE ]]
link:
~/.gitconfig:

- if: [[ $PROFILE = work ]]
link:
~/.gitconfig: gitconfig.work
~/.pairs
# other work-only links
```

Plus, I could imagine this being useful with other directives -- definitely for `shell` and `create`, and probably for many plugins, too.

I think this small enhancement would make dotbot so much more flexible and powerful.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.