Skip to content

Commit 1fe37f3

Browse files
committed
fix πŸ› (colima): implement load colima zsh (#43)
Signed-off-by: Luis Mayta <luis@hadenlabs.com>
1 parent a252f76 commit 1fe37f3

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

β€Žinternal/colima.zshβ€Ž

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@ function container::internal::container::install {
77
fi
88
message_info "Installing ${ZSH_DOCKER_PACKAGE_NAME}"
99
core::install colima
10+
11+
if ! core::exists docker; then
12+
core::install docker
13+
fi
14+
1015
message_success "Installed ${ZSH_DOCKER_PACKAGE_NAME}"
1116
}
1217

13-
function container::internal::container::load {
14-
# Check if jq is installed
15-
if ! command -v jq >/dev/null 2>&1; then
16-
echo "❌ 'jq' is required but not installed. Please install it with: brew install jq"
18+
function check_command {
19+
if ! command -v "$1" >/dev/null 2>&1; then
20+
echo "❌ '$1' is required but not installed. Please install it with: brew install $1"
1721
return 1
1822
fi
23+
return 0
24+
}
1925

20-
# Check if colima is installed
21-
if ! command -v colima >/dev/null 2>&1; then
22-
echo "❌ 'colima' is required but not installed. Please install it with: brew install colima"
23-
return 1
24-
fi
26+
function container::internal::container::load {
27+
check_command jq || return 1
28+
check_command colima || return 1
2529

26-
# Get current Colima machine status
2730
local status
28-
status=$(colima status --json | jq -r '.status')
31+
if ! status=$(colima status --json 2>/dev/null | jq -r '.status'); then
32+
echo "⚠️ Could not get Colima status. Starting Colima..."
33+
colima start
34+
return
35+
fi
2936

3037
if [[ "$status" != "Running" ]]; then
3138
echo "πŸš€ Colima is not running. Starting Colima..."
3239
colima start
3340
fi
34-
}
41+
}

0 commit comments

Comments
Β (0)