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
 | 
			
		||||
	done
 | 
			
		||||
	# Early hook for help
 | 
			
		||||
	[ -n "$_opthelp" ] && printhelp && exit 0
 | 
			
		||||
	# Parse out a config file if it exists
 | 
			
		||||
	if [ -f "$_optconfigfile" ]; then
 | 
			
		||||
		log "Loading config file" 2
 | 
			
		||||
@@ -370,6 +372,8 @@ main() {
 | 
			
		||||
		_args+=("$arg")
 | 
			
		||||
	done
 | 
			
		||||
	# 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
 | 
			
		||||
				if [ "$backend" = "${_config[backend]}" ]; then
 | 
			
		||||
@@ -378,7 +382,8 @@ main() {
 | 
			
		||||
			done
 | 
			
		||||
			return 1
 | 
			
		||||
		) || error "Unsupported backend: ${_config[backend]}" 50
 | 
			
		||||
	if [ -z "$_optmachinemode" ] && ! backend-validate; then
 | 
			
		||||
		# Ensure we meet its requirements
 | 
			
		||||
		if ! backend-validate; then
 | 
			
		||||
			errorcode=$?
 | 
			
		||||
			case $errorcode in
 | 
			
		||||
				1)
 | 
			
		||||
@@ -389,11 +394,8 @@ main() {
 | 
			
		||||
					;;
 | 
			
		||||
			esac
 | 
			
		||||
		fi
 | 
			
		||||
 | 
			
		||||
	# Pre-really-do-stuff hooks like help text
 | 
			
		||||
	[ -n "$_opthelp" ] && printhelp && exit 0
 | 
			
		||||
 | 
			
		||||
	# Ensure we're ready to do the do
 | 
			
		||||
	fi
 | 
			
		||||
	# Validate core program dependencies
 | 
			
		||||
	log "Validating dependencies" 2
 | 
			
		||||
	if ! has youtube-dl pgrep; then
 | 
			
		||||
		error "Failed to find program: $_return" 1
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user