Replies: 6 comments 4 replies
-
Well, this functionality does not exist, except the This can be quite easily achieved by adding a What is the advantage of defining it in the YAML? # lib/require_docker.sh
require_docker() {
# Ensure that Docker is running...
if ! docker info > /dev/null 2>&1; then
echo "Docker is not running!"
exit 1
fi
}
# any_command.sh
require_docker
# rest of the command... |
Beta Was this translation helpful? Give feedback.
-
By the way:
If you feel we should still explore this route, I am open to it. |
Beta Was this translation helpful? Give feedback.
-
I am testing a |
Beta Was this translation helpful? Give feedback.
-
Great! Thank you for considering this feature. The lib dependencies works just as fine. I do like the option to define it in the yaml to keep command configuration in a single place but it doesn’t bring any extra value as you mentioned. Just a personal preference. If you decide not to move forward with this, I can still accomplish what I need without it 😄 |
Beta Was this translation helpful? Give feedback.
-
Excellent, thanks for the suggestion - I will release. |
Beta Was this translation helpful? Give feedback.
-
This is released as 0.7.4 with documentation here and example here. |
Beta Was this translation helpful? Give feedback.
-
Not sure if this already exists as a feature or if there is a clean way to do this, but it would be nice to define a "middleware" layer on commands that would allow for reusing bash logic for whether the command should run or not, for example, say you have several commands that require docker to be running, it would be useful if I could just do something like this in a command definition
Where
docker_is_running
is just a script insrc/middleware/docker_is_running.sh
or an available function on path calleddocker_is_running
That could look something like:
Im basically looking for something similar to arg validation: https://bashly.dannyb.co/advanced/validations/#custom-validations
but at the command execution level if that makes sense.
This makes it a bit easier to reuse the logic for checking if a command is allowed to be called in your cli command sh files/scripts.
Beta Was this translation helpful? Give feedback.
All reactions