-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-switch.sh
More file actions
executable file
·77 lines (63 loc) · 2.74 KB
/
cli-switch.sh
File metadata and controls
executable file
·77 lines (63 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Function to print success message
print_success() {
echo "${GREEN}${BOLD}✓ $1${NC}"
}
# Function to print info message
print_info() {
echo "${BLUE}${BOLD}→ $1${NC}"
}
# CLI configuration switcher
# Cycles through cli-local.yml -> cli-xp130.yml -> cli-xp230.yml -> cli-local.yml
echo "${BOLD}${BLUE}"
echo " ██████╗██╗ ██╗ ███████╗██╗ ██╗██╗████████╗ ██████╗██╗ ██╗"
echo "██╔════╝██║ ██║ ██╔════╝██║ ██║██║╚══██╔══╝██╔════╝██║ ██║"
echo "██║ ██║ ██║ ███████╗██║ █╗ ██║██║ ██║ ██║ ███████║"
echo "██║ ██║ ██║ ╚════██║██║███╗██║██║ ██║ ██║ ██╔══██║"
echo "╚██████╗███████╗██║ ███████║╚███╔███╔╝██║ ██║ ╚██████╗██║ ██║"
echo " ╚═════╝╚══════╝╚═╝ ╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝"
echo "${NC}"
echo "${BOLD}CLI Configuration Switcher${NC}"
echo ""
# Define the configuration files in order
configs="cli-local.yml cli-xp130.yml cli-xp230.yml"
# Check current configuration
current=""
if [ -L "cli.yml" ]; then
current=$(readlink cli.yml)
print_info "Current configuration: ${current}"
else
print_info "No current configuration found"
fi
# Find current config and determine next configuration
next_config=""
found=0
for config in $configs; do
if [ "$found" = "1" ]; then
next_config="$config"
break
fi
if [ "$config" = "$current" ]; then
found=1
fi
done
# If no next config found (current is last or not found), start with first config
if [ -z "$next_config" ]; then
next_config="cli-local.yml"
fi
print_info "Switching to: ${next_config}"
# Remove existing cli.yml and create new symlink
rm -f cli.yml
ln -s "$next_config" cli.yml
print_success "Successfully switched CLI configuration to: ${next_config}"
echo ""
echo "${GREEN}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo "${GREEN}Configuration switch completed!${NC}"
echo ""