-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxbps-slay
More file actions
executable file
·138 lines (125 loc) · 3.79 KB
/
Copy pathxbps-slay
File metadata and controls
executable file
·138 lines (125 loc) · 3.79 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# make submenu for different xbps-src commands, like extract and patch and clean
# options for patching and repolocking
# option for force install
# gum filter returns 'nothing selected' if escaped, so [[ -n $searched ]] doesn't work
# maybe try if $searched == 'nothing selected'; then style 'no package selected'; exit 0
set -euo pipefail
trap 'gum style \
--foreground=13 \
--border="normal" \
--border-foreground=9 \
--margin="1 1" \
--padding="1 1" \
--italic \
"something failed." \
"try checking for required" \
"files, internet, or git" \
"config for mistakes."' ERR
SRC_TREE="$XDG_DATA_HOME/void-packages"
cd "$SRC_TREE"
welcome(){
gum choose \
--header="choose action: " \
--cursor="- " \
--header.foreground=10 \
--cursor.foreground=9 \
--item.foreground=13 \
"search" "build" "create" "exit"
}
confirm(){
gum confirm \
--prompt.foreground=7 \
--affirmative=yes \
--negative=no \
--unselected.background=7 \
--unselected.foreground=8 \
--selected.background=9 \
--selected.foreground=15 \
"${1} ${2}?"
}
input(){
gum input \
--placeholder="$1" \
--placeholder.foreground=7 \
--prompt.foreground=15 \
--cursor.foreground=14
}
spin(){
local title="$1"
shift
gum spin \
--spinner="jump" \
--spinner.foreground=10 \
--title.foreground=15 \
--title="$title" \
-- "$@"
}
style(){
gum style \
--foreground=15 \
--border="normal" \
--border-foreground=9 \
--margin="1 1" \
--padding="1 1" \
--italic \
"$@"
}
update(){
git checkout master 1>/dev/null
spin "updating local repo, please wait..." git pull upstream master
}
custom(){
if git show-ref --quiet refs/head/"${1}-template"; then
style "branch '${1}-template' already exists." "checking out..."
git checkout "${1}-template"
else
git checkout -b "${1}-template"
fi
xnew "$1"
confirm "edit template for" "$1" && nvim srcpkgs/${1}/template
confirm "generate checksum for" "$1" && xgensum -i "$1"
confirm "install" "$1" && install "$1"
}
install(){
./xbps-src pkg "$1"
confirm "install" "$1" && doas xi "$1"
}
while true; do
menu=$(welcome)
case "$menu" in
"search")
searched=$(ls srcpkgs | gum filter --placeholder="search in void source tree...")
if [[ -n "$searched" ]]; then
confirm "build" "$searched" && install "$searched"
else
style "no package entered."
fi
;;
"build")
update
inputted=$(input "enter package name...")
if [[ -n "$inputted" ]]; then
install "$inputted"
else
style "no package entered."
fi
;;
"create")
custompkg=$(input "enter custom pkg name...")
if [[ -n "$custompkg" ]]; then
custom "$custompkg"
else
style "no package entered."
fi
;;
"exit")
spin "exiting..." sleep 1
break
;;
*)
style "something went wrong..." "try again."
exit 1
;;
esac
done