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

function __fish_alpm_repo_desc_needs_command
	# Figure out if the current invocation already has a command.
	set -l cmd (commandline -opc)
	set -e cmd[1]
	argparse -s (__fish_alpm_repo_desc_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_alpm_repo_desc_using_subcommand
	set -l cmd (__fish_alpm_repo_desc_needs_command)
	test -z "$cmd"
	and return 1
	contains -- $cmd[1] $argv
end

complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -s h -l help -d 'Print help'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -s V -l version -d 'Print version'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -f -a "create" -d 'Create a package repository desc file according to a schema'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -f -a "validate" -d 'Validate a package repository desc file according to a schema'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -f -a "format" -d 'Parse and output a package repository desc file in a different format'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and not __fish_seen_subcommand_from v1 v2 help" -s h -l help -d 'Print help'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and not __fish_seen_subcommand_from v1 v2 help" -f -a "v1" -d 'Create a package repository desc version 1 file'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and not __fish_seen_subcommand_from v1 v2 help" -f -a "v2" -d 'Create a package repository desc version 2 file'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and not __fish_seen_subcommand_from v1 v2 help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l filename -d 'The package file name' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l name -d 'The package name' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l base -d 'The name of the package base, from which this package originates' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l version -d 'The version of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l description -d 'The description of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l groups -d 'The groups this package belongs to' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l csize -d 'The compressed size of the package in bytes' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l isize -d 'The size of the uncompressed and unpacked package contents in bytes' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l sha256sum -d 'The SHA256 checksum of the package file' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l url -d 'The optional URL associated with the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l license -d 'Set of licenses under which the package is distributed' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l arch -d 'The architecture of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l builddate -d 'The date at wchich the build of the package started' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l packager -d 'The User ID of the entity, that built the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l replaces -d 'Virtual components or packages that this package replaces upon installation' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l conflicts -d 'Virtual components or packages that this package conflicts with' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l provides -d 'Virtual components or packages that this package provides' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l depends -d 'Run-time dependencies required by the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l optdepends -d 'Optional dependencies that are not strictly required by the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l makedepends -d 'Dependencies for building the upstream software of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l checkdepends -d 'A dependency for running tests of the package\'s upstream project' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l md5sum -d 'The MD5 checksum of the package file' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -l pgpsig -d 'The base64-encoded OpenPGP detached signature of the package file' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v1" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l filename -d 'The package file name' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l name -d 'The package name' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l base -d 'The name of the package base, from which this package originates' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l version -d 'The version of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l description -d 'The description of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l groups -d 'The groups this package belongs to' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l csize -d 'The compressed size of the package in bytes' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l isize -d 'The size of the uncompressed and unpacked package contents in bytes' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l sha256sum -d 'The SHA256 checksum of the package file' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l url -d 'The optional URL associated with the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l license -d 'Set of licenses under which the package is distributed' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l arch -d 'The architecture of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l builddate -d 'The date at wchich the build of the package started' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l packager -d 'The User ID of the entity, that built the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l replaces -d 'Virtual components or packages that this package replaces upon installation' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l conflicts -d 'Virtual components or packages that this package conflicts with' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l provides -d 'Virtual components or packages that this package provides' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l depends -d 'Run-time dependencies required by the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l optdepends -d 'Optional dependencies that are not strictly required by the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l makedepends -d 'Dependencies for building the upstream software of the package' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l checkdepends -d 'A dependency for running tests of the package\'s upstream project' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -l pgpsig -d 'The base64-encoded OpenPGP detached signature of the package file' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from v2" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from help" -f -a "v1" -d 'Create a package repository desc version 1 file'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from help" -f -a "v2" -d 'Create a package repository desc version 2 file'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand create; and __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand validate" -s s -l schema -d 'Provide the schema version to use' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand validate" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand format" -s s -l schema -d 'Provide the schema version to use' -r
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand format" -s o -l output-format -d 'Provide the output format' -r -f -a "json\t'The JSON output format'"
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand format" -s p -l pretty -d 'Pretty-print the output'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand format" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and not __fish_seen_subcommand_from create validate format help" -f -a "create" -d 'Create a package repository desc file according to a schema'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and not __fish_seen_subcommand_from create validate format help" -f -a "validate" -d 'Validate a package repository desc file according to a schema'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and not __fish_seen_subcommand_from create validate format help" -f -a "format" -d 'Parse and output a package repository desc file in a different format'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and not __fish_seen_subcommand_from create validate format help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and __fish_seen_subcommand_from create" -f -a "v1" -d 'Create a package repository desc version 1 file'
complete -c alpm-repo-desc -n "__fish_alpm_repo_desc_using_subcommand help; and __fish_seen_subcommand_from create" -f -a "v2" -d 'Create a package repository desc version 2 file'
