diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-03-04 11:29:13 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-03-04 11:29:13 -0700 |
commit | 26fdc453981df8559af77ec9de71d856079eacf1 (patch) | |
tree | a7014df5bf8988169f740a7733b95ffc12ab1bd7 /andbackup.sh | |
parent | cebce6197936fb12c4ef2a392c718fb134aadc79 (diff) | |
download | andbackup-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.
Diffstat (limited to 'andbackup.sh')
-rwxr-xr-x | andbackup.sh | 40 |
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 } |