summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2017-03-04 11:29:13 -0700
committerAaron Ball <nullspoon@oper.io>2017-03-04 11:29:13 -0700
commit26fdc453981df8559af77ec9de71d856079eacf1 (patch)
treea7014df5bf8988169f740a7733b95ffc12ab1bd7
parentcebce6197936fb12c4ef2a392c718fb134aadc79 (diff)
downloadandbackup-26fdc453981df8559af77ec9de71d856079eacf1.tar.gz
andbackup-26fdc453981df8559af77ec9de71d856079eacf1.tar.xz
Initial commit of usage function
Wrote more helpful helptext for this. Now we print each command, what it does, and each command's additional options. Also added a help command.
-rwxr-xr-xandbackup.sh40
1 files changed, 33 insertions, 7 deletions
diff --git a/andbackup.sh b/andbackup.sh
index 5ada59d..b16f970 100755
--- a/andbackup.sh
+++ b/andbackup.sh
@@ -21,6 +21,35 @@ set -u
backups=/sdcard/andbackup
+usage() {
+ # NOTE: The maximum width of this text should be 68 chars. This
+ # will ensure it displays properly on most devices without
+ # strange wrapping.
+ # If using vim to reflow, execute ':set tw=65'
+ out="
+Andbackup is a basic Android application (or package) backup and
+restore script. It can backup a single application, or a a list
+of applications provided in a text file (one application name per
+line). It can do the same for application restore.
+
+The default backup path is '/sdcard/andbackup/'.
+
+Usage:
+ andbackup.sh <command> [opts]
+
+Commands:
+ help Print this help text
+ backup <app_name> Back up a single package
+ restore <app_name> Restore a single package
+ list List installed packages
+ listbackup <list_file> Backup packages using a list text file
+ listrestore <list_file> Restore packages from a list text file
+
+"
+ printf "${out}"
+}
+
+
log() {
logtype=${1:-}
logmsg=${2:-}
@@ -215,14 +244,11 @@ main() {
list_restore_apps ${@}
elif [ "${cmd}" = 'ls' ] || [ "${cmd}" = 'list' ]; then
list_apps
+ elif [ "${cmd}" = 'help' ]; then
+ usage
else
- printf "Please specify a command\n"
- printf "Available commands are...\n"
- printf " backup\n"
- printf " listbackup\n"
- printf " restore\n"
- printf " listrestore\n"
- printf " list\n"
+ lerror "Unknown command '${cmd}'"
+ usage
return 1
fi
}

Generated by cgit