Skip to content

Commit 1d16a51

Browse files
committed
update and translate script, using ai for best bash script quality
1 parent 235a1d2 commit 1d16a51

File tree

1 file changed

+63
-37
lines changed

1 file changed

+63
-37
lines changed

install.sh

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,88 +49,108 @@ check_command() {
4949
}
5050

5151
install_uv() {
52-
print_step "Проверка uv..."
52+
print_step "Checking uv installation..."
5353

5454
if check_command uv; then
55-
print_success "uv уже установлен"
55+
print_success "uv already installed"
5656
return 0
5757
fi
5858

59-
print_step "Установка uv..."
59+
print_step "Installing uv..."
6060
if curl -fsSL "$UV_INSTALL_URL" | sh; then
61-
print_success "uv успешно установлен"
62-
61+
print_success "uv successfully installed"
6362
export PATH="$HOME/.cargo/bin:$PATH"
64-
6563
return 0
6664
else
67-
print_error "Не удалось установить uv"
65+
print_error "Failed to install uv"
6866
return 1
6967
fi
7068
}
7169

72-
clone_repository() {
73-
print_step "Клонирование репозитория..."
74-
70+
setup_repository() {
7571
if [ -d "$INSTALL_DIR" ]; then
76-
print_info "Директория $INSTALL_DIR уже существует"
77-
read -p "$(echo -e ${YELLOW}Удалить и переустановить? [y/N]:${NC} )" -n 1 -r
72+
print_info "Repository already exists at $INSTALL_DIR"
73+
read -p "$(echo -e ${YELLOW}Update scripts? [Y/n]:${NC} )" -n 1 -r
7874
echo
79-
if [[ $REPLY =~ ^[Yy]$ ]]; then
80-
rm -rf "$INSTALL_DIR"
75+
76+
if [[ $REPLY =~ ^[Nn]$ ]]; then
77+
print_info "Skipping update, using existing version"
78+
return 0
79+
fi
80+
81+
print_step "Updating repository..."
82+
cd "$INSTALL_DIR"
83+
84+
if git pull origin master; then
85+
print_success "Repository updated successfully"
86+
return 0
8187
else
82-
print_info "Пропускаем клонирование"
88+
print_error "Failed to update repository"
89+
return 1
90+
fi
91+
else
92+
print_step "Cloning repository..."
93+
94+
if ! check_command git; then
95+
print_error "Git is not installed. Please install git and try again"
96+
exit 1
97+
fi
98+
99+
if git clone "$REPO_URL" "$INSTALL_DIR"; then
100+
print_success "Repository cloned to $INSTALL_DIR"
83101
return 0
102+
else
103+
print_error "Failed to clone repository"
104+
return 1
84105
fi
85106
fi
107+
}
86108

87-
if ! check_command git; then
88-
print_error "Git не установлен. Установи git и попробуй снова"
89-
exit 1
90-
fi
109+
install_dependencies() {
110+
print_step "Installing dependencies..."
91111

92-
if git clone "$REPO_URL" "$INSTALL_DIR"; then
93-
print_success "Репозиторий склонирован в $INSTALL_DIR"
112+
cd "$INSTALL_DIR"
113+
114+
if uv sync; then
115+
print_success "Dependencies installed successfully"
94116
return 0
95117
else
96-
print_error "Не удалось склонировать репозиторий"
118+
print_error "Failed to install dependencies"
97119
return 1
98120
fi
99121
}
100122

101123
run_script() {
102-
print_step "Запуск скрипта..."
124+
print_step "Running script..."
103125

104126
cd "$INSTALL_DIR"
105127

106128
if uv run main.py; then
107-
print_success "Скрипт выполнен успешно"
129+
print_success "Script executed successfully"
108130
return 0
109131
else
110-
print_error "Ошибка при выполнении скрипта"
132+
print_error "Error executing script"
111133
return 1
112134
fi
113135
}
114136

115137
print_manual_run() {
116138
echo
117139
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
118-
echo -e "${GREEN}${BOLD} Установка завершена!${NC}"
140+
echo -e "${GREEN}${BOLD} Installation completed!${NC}"
119141
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
120142
echo
121-
echo -e "${BOLD}Для запуска скрипта выполни:${NC}"
143+
echo -e "${BOLD}To run the script execute:${NC}"
122144
echo
123145
echo -e " ${MAGENTA}cd $INSTALL_DIR && uv run main.py${NC}"
124146
echo
125-
echo -e "${YELLOW}💡 Совет:${NC} Добавь алиас в ~/.bashrc или ~/.zshrc:"
147+
echo -e "${YELLOW}Tip:${NC} Add alias to ~/.bashrc or ~/.zshrc:"
126148
echo
127149
echo -e " ${CYAN}alias deb='cd $INSTALL_DIR && uv run main.py'${NC}"
128150
echo
129-
echo -e "${CYAN}${BOLD}════════════════════════════════════════════════════${NC}"
151+
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
130152
}
131153

132-
# methods
133-
134154
main() {
135155
clear
136156
print_header
@@ -141,13 +161,19 @@ main() {
141161

142162
echo
143163

144-
if ! clone_repository; then
164+
if ! setup_repository; then
165+
exit 1
166+
fi
167+
168+
echo
169+
170+
if ! install_dependencies; then
145171
exit 1
146172
fi
147173

148174
echo
149175

150-
read -p "$(echo -e ${GREEN}${BOLD}Запустить скрипт сейчас? [Y/n]:${NC} )" -n 1 -r
176+
read -p "$(echo -e ${GREEN}${BOLD}Run script now? [Y/n]:${NC} )" -n 1 -r
151177
echo
152178
echo
153179

@@ -156,9 +182,9 @@ main() {
156182
else
157183
if run_script; then
158184
echo
159-
print_success "Готово!"
185+
print_success "Done!"
160186
echo
161-
print_info "Для повторного запуска используй:"
187+
print_info "To run again use:"
162188
echo -e " ${MAGENTA}cd $INSTALL_DIR && uv run main.py${NC}"
163189
echo
164190
else
@@ -169,8 +195,8 @@ main() {
169195

170196
if [[ ! ":$PATH:" == *":$HOME/.cargo/bin:"* ]]; then
171197
echo
172-
print_info "Возможно, потребуется перезагрузить shell или выполнить:"
173-
echo -e " ${CYAN}source ~/.bashrc${NC} ${YELLOW}# или${NC} ${CYAN}source ~/.zshrc${NC}"
198+
print_info "You may need to reload shell or run:"
199+
echo -e " ${CYAN}source ~/.bashrc${NC} ${YELLOW}or${NC} ${CYAN}source ~/.zshrc${NC}"
174200
echo
175201
fi
176202
}

0 commit comments

Comments
 (0)