From 071641780d7407f8f36b915e5187e4ff507dee4e Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Sun, 11 Oct 2020 06:42:52 -0400 Subject: [PATCH] Add printout function for args, kwargs --- utils.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/utils.sh b/utils.sh index dd62a9b..c07404b 100755 --- a/utils.sh +++ b/utils.sh @@ -493,6 +493,92 @@ function display_text_colors () { echo "" } + +### + # Prints out all current flags, args, and kwargs, as determined by handle_args_kwargs() function. + # If function has been called multiple times, then will also print out global values. + ## +function display_args_kwargs () { + echo "" + echo -e "${text_blue}Displaying processed flags, args, and kwargs.${text_reset}" + echo "" + + # Display for flags. + if [[ ${#flags[@]} > 0: ]] + then + echo -e " ${text_purple}Flags${text_reset} (${#flags[@]} Total):" + echo " ${flags[@]}" + else + echo " No Flags Set." + fi + + # Display for args. + if [[ ${#args[@]} > 0 ]] + then + echo -e " ${text_purple}Args${text_reset} (${#args[@]} Total):" + for index in ${!args[@]} + do + echo " ${index}: ${args[${index}]}" + done + else + echo " No Args Set." + fi + + # Display for kwargs. + if [[ ${#kwargs[@]} > 0 ]] + then + echo -e " ${text_purple}Kwargs${text_reset} (${#kwargs[@]} Total):" + for key in ${!kwargs[@]} + do + echo " ${key}: ${kwargs[${key}]}" + done + else + echo " No Kwargs Set." + fi + + # Only display if global values are different. + if [[ ${flags[@]} != ${global_flags[@]} || ${args[@]} != ${global_args[@]} || ${kwargs[@]} != ${global_kwargs[@]} ]] + then + echo "" + echo "" + + # Display for global flags. + if [[ ${#global_flags[@]} > 0: ]] + then + echo -e " ${text_purple}Global Flags${text_reset} (${#global_flags[@]} Total):" + echo " ${global_flags[@]}" + else + echo " No Global Flags Set." + fi + + # Display for global args. + if [[ ${#global_args[@]} > 0 ]] + then + echo -e " ${text_purple}Global Args${text_reset} (${#global_args[@]} Total):" + for index in ${!global_args[@]} + do + echo " ${index}: ${global_args[${index}]}" + done + else + echo " No Global Args Set." + fi + + # Display for global kwargs. + if [[ ${#global_kwargs[@]} > 0 ]] + then + echo -e " ${text_purple}Global Kwargs${text_reset} (${#global_kwargs[@]} Total):" + for key in ${!global_kwargs[@]} + do + echo " ${key}: ${global_kwargs[${key}]}" + done + else + echo " No Global Kwargs Set." + fi + fi + + echo "" +} + #endregion Other Functions -- GitLab