Reorganize pre-flight checks
Dude why the fuck did you have to have a valid backend to check the help text What was I smoking
This commit is contained in:
		
							
								
								
									
										14
									
								
								ptgdp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ptgdp
									
									
									
									
									
								
							@@ -349,6 +349,8 @@ main() {
 | 
				
			|||||||
				;;
 | 
									;;
 | 
				
			||||||
		esac
 | 
							esac
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 | 
						# Early hook for help
 | 
				
			||||||
 | 
						[ -n "$_opthelp" ] && printhelp && exit 0
 | 
				
			||||||
	# Parse out a config file if it exists
 | 
						# Parse out a config file if it exists
 | 
				
			||||||
	if [ -f "$_optconfigfile" ]; then
 | 
						if [ -f "$_optconfigfile" ]; then
 | 
				
			||||||
		log "Loading config file" 2
 | 
							log "Loading config file" 2
 | 
				
			||||||
@@ -370,6 +372,8 @@ main() {
 | 
				
			|||||||
		_args+=("$arg")
 | 
							_args+=("$arg")
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	# Validate critical options
 | 
						# Validate critical options
 | 
				
			||||||
 | 
						if [ -z "$_optmachinemode" ]; then
 | 
				
			||||||
 | 
							# Ensure we have a good backend, assuming we're not in a scripting mode
 | 
				
			||||||
		(
 | 
							(
 | 
				
			||||||
			for backend in ${_supportedbackends[@]}; do
 | 
								for backend in ${_supportedbackends[@]}; do
 | 
				
			||||||
				if [ "$backend" = "${_config[backend]}" ]; then
 | 
									if [ "$backend" = "${_config[backend]}" ]; then
 | 
				
			||||||
@@ -378,7 +382,8 @@ main() {
 | 
				
			|||||||
			done
 | 
								done
 | 
				
			||||||
			return 1
 | 
								return 1
 | 
				
			||||||
		) || error "Unsupported backend: ${_config[backend]}" 50
 | 
							) || error "Unsupported backend: ${_config[backend]}" 50
 | 
				
			||||||
	if [ -z "$_optmachinemode" ] && ! backend-validate; then
 | 
							# Ensure we meet its requirements
 | 
				
			||||||
 | 
							if ! backend-validate; then
 | 
				
			||||||
			errorcode=$?
 | 
								errorcode=$?
 | 
				
			||||||
			case $errorcode in
 | 
								case $errorcode in
 | 
				
			||||||
				1)
 | 
									1)
 | 
				
			||||||
@@ -389,11 +394,8 @@ main() {
 | 
				
			|||||||
					;;
 | 
										;;
 | 
				
			||||||
			esac
 | 
								esac
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
	# Pre-really-do-stuff hooks like help text
 | 
						# Validate core program dependencies
 | 
				
			||||||
	[ -n "$_opthelp" ] && printhelp && exit 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# Ensure we're ready to do the do
 | 
					 | 
				
			||||||
	log "Validating dependencies" 2
 | 
						log "Validating dependencies" 2
 | 
				
			||||||
	if ! has youtube-dl pgrep; then
 | 
						if ! has youtube-dl pgrep; then
 | 
				
			||||||
		error "Failed to find program: $_return" 1
 | 
							error "Failed to find program: $_return" 1
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user