add in-script help
This commit is contained in:
		
							parent
							
								
									9ef05505a6
								
							
						
					
					
						commit
						71b77857a6
					
				
							
								
								
									
										6
									
								
								.vscode/numbered-bookmarks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.vscode/numbered-bookmarks.json
									
									
									
									
										vendored
									
									
								
							| @ -4,15 +4,15 @@ | |||||||
| 			"fsPath": "$ROOTPATH$/borghelper.sh", | 			"fsPath": "$ROOTPATH$/borghelper.sh", | ||||||
| 			"bookmarks": [ | 			"bookmarks": [ | ||||||
| 				-1, | 				-1, | ||||||
| 				151, | 				215, | ||||||
| 				168, | 				232, | ||||||
| 				-1, | 				-1, | ||||||
| 				-1, | 				-1, | ||||||
| 				-1, | 				-1, | ||||||
| 				-1, | 				-1, | ||||||
| 				-1, | 				-1, | ||||||
| 				-1, | 				-1, | ||||||
| 				105 | 				169 | ||||||
| 			] | 			] | ||||||
| 		} | 		} | ||||||
| 	] | 	] | ||||||
|  | |||||||
| @ -23,10 +23,66 @@ consoleError() { | |||||||
|     exit "$1" |     exit "$1" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | scriptHelp() { | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${bold}Usage: borghelper.sh [parameters]${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "Simple script to read connection parameters from a flat text file and process borg 'info', 'list' and 'restore' commands without the very long command lines that are required when specifying repo names and passwords, etc." | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}The script has the following parameters:${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}--- Required Parameters ---${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     ptextblock "-v|--vars" | ||||||
|  |     textblock "Path to the .borgvars file from which to read borg connection information. This is not required if run with '--makevars'." | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}--- Operation Modes ---${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     ptextblock "--makevars" | ||||||
|  |     textblock "Create a sample .borgvars file that you can fill in and use with this script." | ||||||
|  |     ptextblock "-i|--info" | ||||||
|  |     textblock "Get information about a specified borg repo archive. Requires you supply '--archive'." | ||||||
|  |     ptextblock "-l|--list" | ||||||
|  |     textblock "List contents of a specified borg repo archive. Requires you supply '--archive'." | ||||||
|  |     ptextblock "-la|--list-all" | ||||||
|  |     textblock "List all available archives within the repo specified in your .borgvars file." | ||||||
|  |     ptextblock "-r|--restore" | ||||||
|  |     textblock "Restore the specified borg repo archive/file(s). Requires you supply '--archive'." | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}--- Selector Parameters ---${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     ptextblock "-a|--archive" | ||||||
|  |     textblock "The archive within your borg repo you wish to work with." | ||||||
|  |     ptextblock "--exclude" | ||||||
|  |     textblock "Pattern (python/borg) of files to exclude from a restore operation." | ||||||
|  |     ptextblock "-f|--file" | ||||||
|  |     textblock "Specific file/pattern (python/borg) you want to restore from an archive. Requires that you supply '--archive'." | ||||||
|  |     ptextblock "-p|--path" | ||||||
|  |     textblock "Path to which you want your archive/files restored. This script will attempt to create the directory for you if it does not already exist." | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}--- Restore Options ---${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     ptextblock "--progress" | ||||||
|  |     textblock "Display progress indicator during restore operations. WARNING: This can drastically slow down operations on larger archives!" | ||||||
|  |     ptextblock "--verbose" | ||||||
|  |     textblock "List the individual files being processed during restore operations." | ||||||
|  |     printf "\n" | ||||||
|  |     textblock "${magenta}--- Other Parameters ---${norm}" | ||||||
|  |     printf "\n" | ||||||
|  |     ptextblock "-h|-?|--help" | ||||||
|  |     textblock "This help screen." | ||||||
|  |     printf "\n" | ||||||
|  |     exit 0 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| textblock() { | textblock() { | ||||||
|     printf "%s\n" "$1" | fold -w "$width" -s |     printf "%s\n" "$1" | fold -w "$width" -s | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | ptextblock() { | ||||||
|  |     printf "%s%s%s\n" "$cyan" "$1" "$norm" | ||||||
|  | } | ||||||
|  | 
 | ||||||
| trapExit () { | trapExit () { | ||||||
|     cleanup |     cleanup | ||||||
|     printf "%s\nScript execution terminated via signal.\n\n%s" "$err" "$norm" |     printf "%s\nScript execution terminated via signal.\n\n%s" "$err" "$norm" | ||||||
| @ -36,12 +92,20 @@ trapExit () { | |||||||
| 
 | 
 | ||||||
| ### text formatting presets | ### text formatting presets | ||||||
| if command -v tput > /dev/null; then | if command -v tput > /dev/null; then | ||||||
|  |     bold=$(tput bold) | ||||||
|  |     cyan=$(tput setaf 6) | ||||||
|     err=$(tput bold)$(tput setaf 1) |     err=$(tput bold)$(tput setaf 1) | ||||||
|  |     magenta=$(tput setaf 5) | ||||||
|     norm=$(tput sgr0) |     norm=$(tput sgr0) | ||||||
|  |     yellow=$(tput setaf 3) | ||||||
|     width=$(tput cols) |     width=$(tput cols) | ||||||
| else | else | ||||||
|  |     bold="" | ||||||
|  |     cyan="" | ||||||
|     err="[ERROR] " |     err="[ERROR] " | ||||||
|  |     magenta="" | ||||||
|     norm="" |     norm="" | ||||||
|  |     yellow="" | ||||||
|     width=80 |     width=80 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| @ -87,7 +151,7 @@ while [ $# -gt 0 ]; do | |||||||
|             ;; |             ;; | ||||||
|         -h|-\?|--help) |         -h|-\?|--help) | ||||||
|             # display help |             # display help | ||||||
|             printf "\nStill working on the help text :-)\n\n" |             scriptHelp | ||||||
|             exit 0 |             exit 0 | ||||||
|             ;; |             ;; | ||||||
|         -i|--info) |         -i|--info) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user