Cleanup conditional construction logic for --resolved and --user
Signed-off-by: Joey Armstrong <jarmstrong@linuxfoundation.org>
Change-Id: I2080713f8c340aa234923e0a226030ec1b666133
diff --git a/jira/jira-search/is_empty/include.sh b/jira/jira-search/is_empty/include.sh
new file mode 100644
index 0000000..0acb0c2
--- /dev/null
+++ b/jira/jira-search/is_empty/include.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+## -----------------------------------------------------------------------
+## Intent: getopts parsing and set flag status for --is-empty swtiches
+## -----------------------------------------------------------------------
+
+## -----------------------------------------------------------------------
+## Intent: Parse command line switch, when *-empty detected take action
+## - remove is-empty OR is-not-empty from swtich string
+## - set values in map %attrs=() to capture detection bits
+## Return:
+## %attrs
+## --is-empty empty=true
+## --is-not-empty empty=true, not=true
+## -----------------------------------------------------------------------
+function getopts_switch__empty()
+{
+ local -n gse_arg=$1; shift
+ declare -g -A attrs
+
+ case "$gse_arg" in
+ *'-is-empty')
+ is_switch_valid__is_empty "$gse_arg"
+ attrs['empty']=1
+ # declare -g -i argv_is_empty=1
+ gse_arg="${gse_arg/-is-empty/}"
+ local -i rc=0
+ ;;
+ *) local -i rc=1 ;;
+ esac
+
+ [[ $rc -eq 0 ]] && { true; } || { false; }
+ return
+}
+
+## -----------------------------------------------------------------------
+## Intent: Define flags based on detected switch modifiers
+## -----------------------------------------------------------------------
+function gen_attrs__empty()
+{
+ local switch="$1"; shift
+ declare -g attrs
+
+ local is="${switch}_is_empty"
+ local not="${switch}_not_empty"
+ declare -g -i "$is"
+ declare -g -i "$not"
+
+ ## Clear prior state
+ [[ -v "$is" ]] && { echo "IS"; unset "$is"; }
+ [[ -v "$not" ]] && { echo "NOT"; unset "$not"; }
+
+ ## Apply current attributes
+ ## [TODO] parameterize flag creation
+ if [[ ! -v attrs['empty'] ]]; then
+ : # fall through
+ elif [[ -v attrs['not'] ]]; then
+ declare -g -i $not=1
+ else
+ declare -g -i $is=1
+ fi
+
+ : # assign ($?==0)
+ return
+}
+
+
+# [EOF]