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 shell commands on cargo command failures #283

Open
roboteng opened this issue Sep 13, 2023 · 1 comment
Open

Feature Request: Run shell commands on cargo command failures #283

roboteng opened this issue Sep 13, 2023 · 1 comment

Comments

@roboteng
Copy link

Currently, shell commands only run after cargo commands run successfully. I'd also like to be able to run a different shell command on cargo command failures. My use case is that I'd like to run a command that plays a success sound on a cargo command success, and a different sound on cargo command failure.

This is what I have right now:

cargo watch -x check -s "afplay ~/bin/success-chime.mp3 & echo ''"

This is what I'd like to see. I'm not sure that this would be the right syntax, but I think it gets the point across:

cargo watch -x check -s "afplay ~/bin/success-chime.mp3 & echo ''" --cargo-failure "afplay ~/bin/error-chime.mp3 & echo ''"

The -s arg gets run after the previous cargo commands pass, and the --cargo-failure arg gets run if cargo doesn't complete successfully.

What should the syntax here be?

@passcod
Copy link
Member

passcod commented Sep 13, 2023

Right now what you should do is

cargo watch -s 'cargo check && success || failure'

where success and failure are the chimes commands you've defined

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