From f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 20 Sep 2017 21:19:05 +0200 Subject: Commit current state --- utils/ops | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils/ops (limited to 'utils/ops') diff --git a/utils/ops b/utils/ops new file mode 100644 index 0000000..1365ec8 --- /dev/null +++ b/utils/ops @@ -0,0 +1,30 @@ +# vim:ft=sh:noexpandtab +# Utility functions for operations + +# Set operation we are working on +ops_set_current() { + OPERATION_CURRENT="$1" +} + +ops_require() { + while [ $# -gt 0 ]; do + dict_set "ops/$OPERATION_CURRENT" "$1" true + shift + done +} + +ops_required_any() { + if ! dict_empty "ops/$OPERATION_CURRENT"; then + echo_warn "$1 requires update for following components: $(ops_required_list)" + else + return 1 + fi +} + +ops_is_required() { + dict_contains "ops/$OPERATION_CURRENT" "$1" +} + +ops_required_list() { + dict_keys "ops/$OPERATION_CURRENT" +} -- cgit v1.2.3