# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_sqopv_global_optspecs
	string join \n debug h/help
end

function __fish_sqopv_needs_command
	# Figure out if the current invocation already has a command.
	set -l cmd (commandline -opc)
	set -e cmd[1]
	argparse -s (__fish_sqopv_global_optspecs) -- $cmd 2>/dev/null
	or return
	if set -q argv[1]
		# Also print the command, so this can be used to figure out what it is.
		echo $argv[1]
		return 1
	end
	return 0
end

function __fish_sqopv_using_subcommand
	set -l cmd (__fish_sqopv_needs_command)
	test -z "$cmd"
	and return 1
	contains -- $cmd[1] $argv
end

complete -c sqopv -n "__fish_sqopv_needs_command" -l debug -d 'Emit verbose output for debugging'
complete -c sqopv -n "__fish_sqopv_needs_command" -s h -l help -d 'Print help'
complete -c sqopv -n "__fish_sqopv_needs_command" -f -a "version" -d 'Prints version information'
complete -c sqopv -n "__fish_sqopv_needs_command" -f -a "verify" -d 'Verifies Detached Signatures'
complete -c sqopv -n "__fish_sqopv_needs_command" -f -a "inline-verify" -d 'Verifies Inline-Signed Messages'
complete -c sqopv -n "__fish_sqopv_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -l backend -d 'Returns name and version of the primary underlying OpenPGP toolkit'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -l extended -d 'Returns multiple lines of name and version information'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -l sop-spec -d 'Returns the latest version of the SOP spec that is implemented'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -l sopv -d 'Returns "1.0\\n" if the sopv subset is implemented'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -l debug -d 'Emit verbose output for debugging'
complete -c sqopv -n "__fish_sqopv_using_subcommand version" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c sqopv -n "__fish_sqopv_using_subcommand verify" -l not-before -d 'Consider signatures before this date invalid' -r
complete -c sqopv -n "__fish_sqopv_using_subcommand verify" -l not-after -d 'Consider signatures after this date invalid' -r
complete -c sqopv -n "__fish_sqopv_using_subcommand verify" -l debug -d 'Emit verbose output for debugging'
complete -c sqopv -n "__fish_sqopv_using_subcommand verify" -s h -l help -d 'Print help'
complete -c sqopv -n "__fish_sqopv_using_subcommand inline-verify" -l not-before -d 'Consider signatures before this date invalid' -r
complete -c sqopv -n "__fish_sqopv_using_subcommand inline-verify" -l not-after -d 'Consider signatures after this date invalid' -r
complete -c sqopv -n "__fish_sqopv_using_subcommand inline-verify" -l verifications-out -d 'Write verification result here' -r
complete -c sqopv -n "__fish_sqopv_using_subcommand inline-verify" -l debug -d 'Emit verbose output for debugging'
complete -c sqopv -n "__fish_sqopv_using_subcommand inline-verify" -s h -l help -d 'Print help'
complete -c sqopv -n "__fish_sqopv_using_subcommand help; and not __fish_seen_subcommand_from version verify inline-verify help" -f -a "version" -d 'Prints version information'
complete -c sqopv -n "__fish_sqopv_using_subcommand help; and not __fish_seen_subcommand_from version verify inline-verify help" -f -a "verify" -d 'Verifies Detached Signatures'
complete -c sqopv -n "__fish_sqopv_using_subcommand help; and not __fish_seen_subcommand_from version verify inline-verify help" -f -a "inline-verify" -d 'Verifies Inline-Signed Messages'
complete -c sqopv -n "__fish_sqopv_using_subcommand help; and not __fish_seen_subcommand_from version verify inline-verify help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
