updated presentation
This commit is contained in:
parent
68b479221d
commit
46033632df
37
flist.sh
37
flist.sh
@ -4,6 +4,11 @@
|
||||
TOKEN_FILE="$HOME/.config/tfhubtoken"
|
||||
BINARY_LOCATION="/usr/local/bin/flist"
|
||||
|
||||
error_message() {
|
||||
echo "$(tput bold)$(tput setaf 1)Error:$(tput sgr0) $1"
|
||||
echo "$(tput setaf 3)Run 'flist help' for usage information.$(tput sgr0)"
|
||||
}
|
||||
|
||||
install() {
|
||||
echo "Installing Flist CLI..."
|
||||
if [ -f "$0" ]; then
|
||||
@ -12,7 +17,7 @@ install() {
|
||||
echo "Flist CLI has been installed to $BINARY_LOCATION"
|
||||
echo "You can now use it by running 'flist help'"
|
||||
else
|
||||
echo "Error: Cannot find the script file"
|
||||
error_message "Cannot find the script file"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -59,7 +64,7 @@ login() {
|
||||
if sudo docker login; then
|
||||
echo "Successfully logged in to Docker Hub."
|
||||
else
|
||||
echo "Failed to log in to Docker Hub."
|
||||
error_message "Failed to log in to Docker Hub."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
@ -71,7 +76,7 @@ login() {
|
||||
|
||||
logout() {
|
||||
if [ ! -f "$TOKEN_FILE" ]; then
|
||||
echo "You are not logged in."
|
||||
error_message "You are not logged in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -83,8 +88,8 @@ logout() {
|
||||
|
||||
push() {
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Error: Incorrect number of parameters."
|
||||
echo "Usage: $0 push <name>:<tag>"
|
||||
error_message "Incorrect number of parameters."
|
||||
echo "Usage: flist push <name>:<tag>"
|
||||
echo "Please provide exactly one parameter."
|
||||
exit 1
|
||||
fi
|
||||
@ -99,7 +104,7 @@ push() {
|
||||
if [ -f "$TOKEN_FILE" ]; then
|
||||
tfhub_token=$(cat "$TOKEN_FILE")
|
||||
else
|
||||
echo "Error: No token found. Please run '$0 login' first."
|
||||
error_message "No token found. Please run 'flist login' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -126,8 +131,8 @@ push() {
|
||||
|
||||
delete() {
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Error: Incorrect number of parameters."
|
||||
echo "Usage: $0 delete <flist_name>"
|
||||
error_message "Incorrect number of parameters."
|
||||
echo "Usage: flist delete <flist_name>"
|
||||
echo "Please provide exactly one parameter."
|
||||
exit 1
|
||||
fi
|
||||
@ -137,7 +142,7 @@ delete() {
|
||||
if [ -f "$TOKEN_FILE" ]; then
|
||||
tfhub_token=$(cat "$TOKEN_FILE")
|
||||
else
|
||||
echo "Error: No token found. Please run '$0 login' first."
|
||||
error_message "No token found. Please run 'flist login' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -148,8 +153,8 @@ delete() {
|
||||
|
||||
rename() {
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Error: Incorrect number of parameters."
|
||||
echo "Usage: $0 rename <flist_name> <new_flist_name>"
|
||||
error_message "Incorrect number of parameters."
|
||||
echo "Usage: flist rename <flist_name> <new_flist_name>"
|
||||
echo "Please provide exactly two parameters."
|
||||
exit 1
|
||||
fi
|
||||
@ -160,7 +165,7 @@ rename() {
|
||||
if [ -f "$TOKEN_FILE" ]; then
|
||||
tfhub_token=$(cat "$TOKEN_FILE")
|
||||
else
|
||||
echo "Error: No token found. Please run '$0 login' first."
|
||||
error_message "No token found. Please run 'flist login' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -215,7 +220,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
if [ $# -eq 2 ]; then
|
||||
push "$2"
|
||||
else
|
||||
echo "Usage: $0 push <image>:<tag>"
|
||||
error_message "Incorrect number of arguments for 'push'."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@ -229,7 +234,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
if [ $# -eq 2 ]; then
|
||||
delete "$2"
|
||||
else
|
||||
echo "Usage: $0 delete <flist_name>"
|
||||
error_message "Incorrect number of arguments for 'delete'."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@ -237,7 +242,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
if [ $# -eq 3 ]; then
|
||||
rename "$2" "$3"
|
||||
else
|
||||
echo "Usage: $0 rename <flist_name> <new_flist_name>"
|
||||
error_message "Incorrect number of arguments for 'rename'."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@ -245,7 +250,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
help
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command. Use '$0 help' for usage information."
|
||||
error_message "Unknown command: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user