Skip to content

Commit

Permalink
🎈 perf(menu): update cli
Browse files Browse the repository at this point in the history
Update menu options. Refactor update software method
  • Loading branch information
AlbertoVf committed Mar 30, 2023
1 parent fd9a0c3 commit d985aa4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
61 changes: 29 additions & 32 deletions arco-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,33 @@ function helper() {
"
}

while getopts "haescdt" opt; do
case ${opt} in
a)
install_aur
;;
e)
install_extra
;;
s)
install_snap
;;
c)
install_community
;;
d)
install_distro
;;
t)
install_all
;;
h)
function cli() {

if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
helper
;;
\?)
echo "Opción inválida: -$OPTARG" 1>&2
exit 1
;;
:)
echo "La opción -$OPTARG requiere un argumento." 1>&2
exit 1
;;
esac
done
else
update_packages
case $1 in
-a | --aur)
install_aur
;;
-e | --extra)
install_extra
;;
-s | --snap)
install_snap
;;
-c | --community)
install_community
;;
-d | --distro)
install_distro
;;
-t | --all)
install_all
;;
esac
fi
}

cli $@
10 changes: 2 additions & 8 deletions src/format-software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,10 @@ function is_not_installed() {
}

function format_software() {
jq -sRrc 'split("\n") | .[1:] | map(split(";")) | map({"repositorio": .[0], "tags": .[1], "paquete": .[2]})' \
jq -sRrc 'split("\n") | .[1:] | map(split(";")) | map({"paquete": .[2], "repositorio": .[0], "tags": .[1]})' \
$csv_file >$json_file

sed -Ee 's/(\s+\")/\"/g' -i $json_file
green "Software files updated"
}

function update_packages() {
format_software
blue "Updating packages"
sudo reflector --verbose -f 20 -l 15 -n 10 --save /etc/pacman.d/mirrorlist
$installation_command -Syyu
green "Software files updated"
}
6 changes: 5 additions & 1 deletion src/installer.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
source src/format-software.sh

# update_packages
function update_packages() {
format_software
blue "Updating packages"
sudo reflector --verbose -f 20 -l 15 -n 10 --save /etc/pacman.d/mirrorlist && $installation_command -Syyu
}

function install_community() {
info_instalation "Installing community software"
Expand Down

0 comments on commit d985aa4

Please sign in to comment.