-
Notifications
You must be signed in to change notification settings - Fork 17
commands: add new generic --skip-if command line options #120
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
Conversation
cc: @avanthakkar - for an additional review & peek into this code base |
🎉 All dependencies have been resolved ! |
d8ebc59
to
77f9375
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but see minor comments
77f9375
to
6b33889
Compare
I noticed a stray debugging print statement was still in the unit test file. It's now removed. |
Add a generic lib for skipping the execution of a sambacc command based on file presence or environment variable contents. There's also an 'always:' rule for completeness & testing purposes. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Previously, sambacc had the `--skip-if-file=` command line option that would skip running a command if a named file exists. I have a need for doing something similar for environment variable contents. In order to avoid needing to add a plethora of new --skip-if-x type options over time, add a more generic `--skip-if=` option and have the value contain an initial prefix like `file:` or `env:` that determines how the rest of the value will be parsed and how the skip will be determined (or not). Deprecate `--skip-if-file`. Maybe it's a case of over engineering, but at least it's easy to unit test. Examples: * `--skip-if=env:CHAT==yes`, if the environment variable `CHAT` contains a value equal to "yes" the command will be skipped * `--skip-if=file:/foo/bar` if the file `/foo/bar` exists the command will be skipped * `--skip-if=file:!/foo/bar` if the file `/foo/bar` does not exist the command will be skipped * `--skip-if=env:MODE!=777`, if the environment variable `MODE` contains a value not equal to "777" the command will be skipped * `--skip-if=always:`, always skip this command (mainly to be used for testing/hacking on things) Signed-off-by: John Mulligan <[email protected]>
6b33889
to
d27b4c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Depends on: #119
Previously, sambacc had the
--skip-if-file=
command line option thatwould skip running a command if a named file exists. I have a need for
doing something similar for environment variable contents. In order to
avoid needing to add a plethora of new --skip-if-x type options over
time, add a more generic
--skip-if=
option and have the value containan initial prefix like
file:
orenv:
that determines how the rest ofthe value will be parsed and how the skip will be determined (or not).
Deprecate
--skip-if-file
.Maybe it's a case of over engineering, but at least it's easy to unit
test.
Examples:
--skip-if=env:CHAT==yes
, if the environment variableCHAT
containsa value equal to "yes" the command will be skipped
--skip-if=file:/foo/bar
if the file/foo/bar
exists the commandwill be skipped
--skip-if=file:!/foo/bar
if the file/foo/bar
does not exist the commandwill be skipped
--skip-if=env:MODE!=777
, if the environment variableMODE
containsa value not equal to "777" the command will be skipped
--skip-if=always:
, always skip this command (mainly to be used fortesting/hacking on things)