Skip to content

Commit 22496e1

Browse files
fiechrFederico Fissore
authored and
Federico Fissore
committed
Added help option for install.sh and changed some texts and comments.
1 parent a84ab52 commit 22496e1

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

build/linux/dist/install.sh

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
RESOURCE_NAME=arduino-arduinoide
1010

1111
# Get absolute path from which this script file was executed
12-
# Use "pwd -P" to resolve symlinks to their target
12+
# (Could be changed to "pwd -P" to resolve symlinks to their target)
1313
SCRIPT_PATH=$( cd $(dirname $0) ; pwd )
1414
cd "$SCRIPT_PATH"
1515

16+
# Default mode is to install.
17+
UNINSTALL=false
18+
1619
# Install using xdg-utils
1720
xdg_install_f() {
1821

@@ -172,24 +175,63 @@ xdg_exists_f() {
172175

173176
}
174177

178+
# Shows a description of the available options
179+
display_help_f() {
180+
echo "\n"
181+
echo "This script will add a Arduino IDE desktop shortcut, menu item,"
182+
echo "icons and file associations for the current user."
183+
if ! xdg_exists_f; then
184+
echo "\n"
185+
echo "xdg-utils are recommended to be installed, so this script can use them."
186+
fi
187+
echo "\n"
188+
echo "Optional arguments are:"
189+
echo "\n"
190+
echo "\t-u, --uninstall\t\tRemoves shortcut, menu item and icons."
191+
echo "\n"
192+
echo "\t-h, --help\t\tShows this help again."
193+
echo "\n"
194+
}
195+
196+
# Check for provided arguments
197+
while [ $# -gt 0 ] ; do
198+
ARG="$1"
199+
case $ARG in
200+
-u|--uninstall)
201+
UNINSTALL=true
202+
shift
203+
;;
204+
-h|--help)
205+
display_help_f
206+
exit 0
207+
;;
208+
*)
209+
echo "\n"
210+
echo "Invalid option -- '$ARG'"
211+
display_help_f
212+
exit 1
213+
;;
214+
esac
215+
done
216+
175217
# If possible, use xdg-utils, if not, use a more basic approach
176218
if xdg_exists_f; then
177-
if [ "$1" = "-u" ]; then
178-
echo "Removing menu item, icons and file association for Arduino IDE..."
219+
if [ "$UNINSTALL" = true ]; then
220+
echo "Removing desktop shortcut and menu item for Arduino IDE..."
179221
xdg_uninstall_f
180222
simple_uninstall_f
181223
else
182-
echo "Adding menu item, icons and file association for Arduino IDE..."
224+
echo "Adding desktop shortcut, menu item and file associations for Arduino IDE..."
183225
xdg_uninstall_f
184226
simple_uninstall_f
185227
xdg_install_f
186228
fi
187229
else
188-
if [ "$1" = "-u" ]; then
189-
echo "Removing menu item for Arduino IDE..."
230+
if [ "$UNINSTALL" = true ]; then
231+
echo "Removing desktop shortcut and menu item for Arduino IDE..."
190232
simple_uninstall_f
191233
else
192-
echo "Adding menu item for Arduino IDE..."
234+
echo "Adding desktop shortcut and menu item for Arduino IDE..."
193235
simple_uninstall_f
194236
simple_install_f
195237
fi

0 commit comments

Comments
 (0)