diff --git a/scripts/_RosTeamWs_Defines.bash b/scripts/_RosTeamWs_Defines.bash index 9b0b195a..7264b78c 100755 --- a/scripts/_RosTeamWs_Defines.bash +++ b/scripts/_RosTeamWs_Defines.bash @@ -227,14 +227,77 @@ function print_and_exit { message=$1 echo "" - echo -e "${RTW_COLOR_ERROR}$message!!! Exiting...${TERMINAL_COLOR_NC}" + echo -e "${RTW_COLOR_ERROR}$message${TERMINAL_COLOR_NC}" if [ ! -z "$2" ]; then echo "" echo -e "${TERMINAL_COLOR_USER_NOTICE}Usage: '$2'${TERMINAL_COLOR_NC}" fi echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}Error has happened. Press + C two times...${TERMINAL_COLOR_NC}" read -p "" - exit 1 + return 2>/dev/null || exit 1 +} + +function print_error { + RosTeamWS_setup_exports + + message=$1 + if [ -n "$message" ]; then + echo "" + echo "${TERMINAL_COLOR_RED}ERROR: ${message}${RAW_TERMINAL_COLOR_NC}" + fi +} + +function print_warning { + RosTeamWS_setup_exports + + message=$1 + if [ -n "$message" ]; then + echo "" + echo "${TERMINAL_COLOR_YELLOW}WARNING: ${message}${RAW_TERMINAL_COLOR_NC}" + fi +} + +function print_info { + RosTeamWS_setup_exports + + message=$1 + if [ -n "$message" ]; then + echo "" + echo "INFO: ${message}" + fi +} + +function print_notifycation { + RosTeamWS_setup_exports + + message=$1 + if [ -n "$message" ]; then + echo "" + echo "${TERMINAL_COLOR_BLUE}NOTE: ${message}${TERMINAL_COLOR_NC}" + fi +} + +function print_success { + RosTeamWS_setup_exports + + message=$1 + if [ -n "$message" ]; then + echo "" + echo "${TERMINAL_COLOR_GREEN}SUCCESS: ${message}${TERMINAL_COLOR_NC}" + fi +} + +function print_usage { + RosTeamWS_setup_exports + + usage=$1 + message=$2 + if [ -n "$usage" ]; then + print_notifycation "$usage" + fi + if [ -n "$message" ]; then + print_info "$message" + fi } function framework_default_paths { diff --git a/scripts/environment/setup.bash b/scripts/environment/setup.bash index 3b9d0d36..1566b174 100644 --- a/scripts/environment/setup.bash +++ b/scripts/environment/setup.bash @@ -69,11 +69,19 @@ if [[ $ros_version == 1 ]]; then print_and_exit "'$WS_FOLDER_1' does not exist. Can not find ROS workspace!" fi + # TODO(destogl): update this as below and put into a function + export ROS_WS=$WS_FOLDER + FILE_TO_SOURCE="$WS_FOLDER/.ros_team_ws_workspace_rc" + if [ -f "$FILE_TO_SOURCE" ]; then + echo -e "${TERMINAL_COLOR_GRAY}Sourcing custom environment variables for the workspace from file: '$FILE_TO_SOURCE'${TERMINAL_COLOR_NC}" + source "$FILE_TO_SOURCE" + fi + export ROS_WS=$WS_FOLDER source "$WS_FOLDER/devel/setup.bash" echo "" - echo "RosTeamWS: Sourced file: $WS_FOLDER/devel/setup.bash" + echo -e "${TERMINAL_COLOR_BLUE}RosTeamWS: Sourced file: $WS_FOLDER/devel/setup.bash${TERMINAL_COLOR_NC}" elif [[ $ros_version == 2 ]]; then @@ -110,6 +118,12 @@ elif [[ $ros_version == 2 ]]; then fi export ROS_WS=$WS_FOLDER + FILE_TO_SOURCE="$WS_FOLDER/.ros_team_ws_workspace_rc" + if [ -f "$FILE_TO_SOURCE" ]; then + echo -e "${TERMINAL_COLOR_LIGHT_BLUE} sourcing custom environment variables for the workspace from file: '$FILE_TO_SOURCE'." + source "$FILE_TO_SOURCE" + fi + # TODO: COLCON_WS is deprecated!! export COLCON_WS=$ROS_WS FILE_TO_SOURCE="$WS_FOLDER/install/setup.bash" diff --git a/scripts/setup-ros-workspace.bash b/scripts/setup-ros-workspace.bash index 5e826058..adee3a67 100755 --- a/scripts/setup-ros-workspace.bash +++ b/scripts/setup-ros-workspace.bash @@ -5,6 +5,16 @@ setup_ws_script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && source $setup_ws_script_own_dir/_RosTeamWs_Defines.bash source $setup_ws_script_own_dir/docker/_RosTeamWs_Docker_Defines.bash + +# TODO(destogl): can we somehow reuse this in each and every script: a function? or source? +if [ -z "$1" ]; then + print_and_exit "No input parameters provided" "$usage" + return 2>/dev/null || exit +elif [[ $1 == "--help" || $1 == "-h" ]]; then + print_and_exit "Here is the usage help for this script:" "$usage" + return 2>/dev/null || exit +fi + check_user_input () { # ros distribution name will be set in ${ros_distro} check_ros_distro "$1"