Skip to content

Commit

Permalink
feat(just): verbose and quiet update messages (#167)
Browse files Browse the repository at this point in the history
Verbose output with just disable-updates and prompts to update each command
  • Loading branch information
bmp authored Dec 7, 2023
1 parent 1acf1a3 commit d641926
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions build/ublue-os-just/10-update.just
Original file line number Diff line number Diff line change
@@ -1,16 +1,69 @@
# vim: set ft=make :

# Update system, flatpaks, and containers all at once
update:
update VERB_LEVEL="full":
#!/usr/bin/env bash
if systemctl is-enabled ublue-update.timer | grep -q enabled;
then
echo "Starting the ublue-update service"
sudo systemctl start ublue-update.service
else
rpm-ostree update
flatpak update -y
distrobox upgrade -a
if [ {{ VERB_LEVEL }} = "help" ]; then
echo "Usage: just update <level>"
echo " <level>: Specify the verbosity level - 'full', 'minimal', or 'prompt'"
echo " Use 'full' to show full output of each command."
echo " Use 'minimal' to show minimal output and indicate success or failure."
echo " Use 'prompt' to prompt the user before running each command."
exit 0
fi

# Function to run commands with appropriate verbosity and approval check
update_command() {
command=$1
case "{{ VERB_LEVEL }}" in
full)
echo "Running $command..."
$command
echo "Completed $command"
;;
minimal)
echo "Running $command..."
$command > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Completed $command"
else
echo "Failed to complete $command"
exit 1
fi
;;
prompt)
printf "Do you want to run %s? [Y/n]: " "$command"
read user_input
user_input=${user_input:-Y} # Default to Y if Enter is pressed
if [ "$user_input" = "Y" ] || [ "$user_input" = "y" ]; then
echo "Running $command..."
$command
echo "Completed $command"
else
echo "Skipped $command"
fi
;;
*)
echo "Invalid level: {{ VERB_LEVEL }}. Please use 'full', 'minimal', 'prompt' or 'help' for usage."
exit 1
;;
esac
}

# Run rpm-ostree update
update_command "rpm-ostree update"

# Run flatpak update
update_command "flatpak update -y"

# Run distrobox upgrade
update_command "distrobox upgrade -a"

fi

# Update device firmware
Expand Down

0 comments on commit d641926

Please sign in to comment.