From 56f0b64d59d473a173d0a54598df404983e1f78f Mon Sep 17 00:00:00 2001 From: Joel McCracken Date: Wed, 4 Dec 2024 19:58:24 -0500 Subject: [PATCH] refactoring --- ws_tool/test/test.bats | 2 +- ws_tool/ws | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ws_tool/test/test.bats b/ws_tool/test/test.bats index 7847f2e9..08d1ea8b 100644 --- a/ws_tool/test/test.bats +++ b/ws_tool/test/test.bats @@ -50,7 +50,7 @@ setup (){ assert_equal "$WS_COMMAND" "doctor" } -@test "process_cli_args parses the workstation name overriding current" { +@test "process_cli_args parses the workstation name overriding env var" { export WORKSTATION_NAME=goofy WS_COMMAND_ARGUMENTS=(-n foofy) process_cli_args diff --git a/ws_tool/ws b/ws_tool/ws index 3e6a77c0..21a82693 100755 --- a/ws_tool/ws +++ b/ws_tool/ws @@ -95,7 +95,8 @@ process_cli_args() { esac done - [ -n "$WORKSTATION_NAME_ARG" ] && WORKSTATION_NAME="$WORKSTATION_NAME_ARG" : + [ -n "$WORKSTATION_NAME_ARG" ] && WORKSTATION_NAME="$WORKSTATION_NAME_ARG" + return 0 } @@ -109,18 +110,14 @@ ws_main() { process_cli_args "${WS_COMMAND_ARGUMENTS[@]}" - if [ -n "$WORKSTATION_SETTINGS_ARG" ]; then - . "$WORKSTATION_SETTINGS_FILE" - fi - - if [ -n "$WORKSTATION_CONFIG_ARG" ]; then - . "$WORKSTATION_CONFIG_ARG" - fi - if [ "$WORKSTATION_VERBOSE" = "true" ]; then set -x fi + [ -n "$WORKSTATION_SETTINGS_ARG" ] && . "$WORKSTATION_SETTINGS_ARG" + + [ -n "$WORKSTATION_CONFIG_ARG" ] && . "$WORKSTATION_CONFIG_ARG" + case "$WS_COMMAND" in bootstrap) bootstrap_command;; doctor) doctor_command;;