-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·82 lines (67 loc) · 2.42 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·82 lines (67 loc) · 2.42 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
78
79
80
81
82
#!/usr/bin/env bash
#
# uninstall.sh — Aidevix CLI'ni olib tashlaydi.
#
# Nima qiladi:
# 1. .bashrc/.zshrc/.profile'dagi ai-cli blokini (avval zaxira olib) olib tashlaydi.
# 2. ~/.local/bin/aidevix symlink'ini o'chiradi.
# 3. Foydalanuvchi konfiguratsiyasini o'chirishni TAKLIF qiladi (so'ramasdan o'chirmaydi).
#
# Exit kodlari: 0 — muvaffaqiyat, 1 — xato.
set -Eeuo pipefail
INSTALL_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
if [[ -r "$INSTALL_DIR/lib/common.sh" ]]; then
# shellcheck source=lib/common.sh
source "$INSTALL_DIR/lib/common.sh"
else
log_info() { printf '[i] %s\n' "$*" >&2; }
log_warn() { printf '[!] %s\n' "$*" >&2; }
log_error() { printf '[x] %s\n' "$*" >&2; }
log_success() { printf '[✓] %s\n' "$*" >&2; }
die() { local c="$1"; shift; log_error "$*"; exit "$c"; }
fi
trap 'die 1 "O\047chirish xato bilan to\047xtadi (qator: $LINENO)."' ERR
readonly USER_CONFIG_DIR="$HOME/.config/ai-cli"
readonly BIN_DIR="$HOME/.local/bin"
readonly CMD_LINK="$BIN_DIR/aidevix"
readonly STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/ai-cli"
readonly MARK_BEGIN="# >>> ai-cli (boshlanish) >>>"
readonly MARK_END="# <<< ai-cli (oxir) <<<"
remove_block_from() {
local rc="$1"
[[ -e "$rc" ]] || return 0
grep -qF "$MARK_BEGIN" "$rc" || { log_info "Blok topilmadi: $rc"; return 0; }
local ts backup tmp
ts="$(date +%Y%m%d-%H%M%S)"
backup="${rc}.aicli-backup-${ts}"
cp -p -- "$rc" "$backup"
log_success "Zaxira yaratildi: $backup"
tmp="$(mktemp)"
sed "/${MARK_BEGIN//\//\\/}/,/${MARK_END//\//\\/}/d" "$rc" >"$tmp"
mv -- "$tmp" "$rc"
log_success "ai-cli bloki olib tashlandi: $rc"
}
main() {
printf '\n%s🧹 Aidevix CLI — o\047chirish%s\n\n' "${C_BOLD:-}" "${C_RESET:-}"
remove_block_from "$HOME/.bashrc"
remove_block_from "$HOME/.zshrc"
remove_block_from "$HOME/.profile"
local f
for f in "$CMD_LINK" "$CMD_LINK.cmd" "$CMD_LINK.ps1"; do
if [[ -L "$f" || -e "$f" ]]; then
rm -f -- "$f"
log_success "Olib tashlandi: $f"
fi
done
if [[ -d "$STATE_DIR" ]]; then
rm -rf -- "$STATE_DIR"
log_success "Holat fayllari olib tashlandi: $STATE_DIR"
fi
if [[ -d "$USER_CONFIG_DIR" ]]; then
log_warn "Foydalanuvchi konfiguratsiyasi hali mavjud: $USER_CONFIG_DIR"
log_warn "O'chirish uchun: rm -rf '$USER_CONFIG_DIR'"
fi
printf '\n'
log_success "Tugadi. Terminalni qayta oching yoki shell rc'ni qayta yuklang."
}
main "$@"