feat(shell): run shell command conditionally#321
Open
Clumsy-Coder wants to merge 2 commits intoanishathalye:masterfrom
Open
feat(shell): run shell command conditionally#321Clumsy-Coder wants to merge 2 commits intoanishathalye:masterfrom
Clumsy-Coder wants to merge 2 commits intoanishathalye:masterfrom
Conversation
## what
- add feature to run shell command (optionally)
## how
- the shell directive will check if the 'if' property is available.
If it is, it will run the command in 'if' property.
If the command results in a return 0 code or 'true', then the
'command' property will run.
If the condition to run the command is a non 0 code or 'false',
the shell command won't run
- dotbot config example:
```yaml
- shell:
- command: echo "this is running on a MacOS"
if: uname -s | grep -i "Darwin"
```
- dotbot config example: skipping command if false
```yaml
- shell:
- command: echo "This command should be skipped"
if: false
```
## why
- can run the shell command conditionally
- can use multiple dotbot configs to run different OS
- Ex: incorporating it in https://github.com/ecarlson94/dotbot-template
## where
- file changed in `./dotbot/plugins/shell.py`
## usage
Create dotbot config
```yaml
- shell:
- command: echo "this is running on a MacOS"
if: uname -s | grep -i "Darwin"
```
```yaml
- shell:
- command: echo "This command should be skipped"
if: false
```
e139213 to
25ef5d5
Compare
## what - add documentation on using shell command conditionally ## how ## why ## where ## usage
Author
|
Pull Request connected to issue #312 |
Author
|
I tested it as much as I can. This is first time working in Python code. So, if issue surfaces, let me know |
|
Hi, I just made the dotbot-if plugin, and found it's sharing the similar idea with this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
how
why
where
./dotbot/plugins/shell.pyusage
Create dotbot config
NOTE
str(item["if"]),falsein strings