# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_acceptarium_global_optspecs
	string join \n v/verbose q/quiet n/dry-run no-dry-run d/dirty no-dirty overwrite no-overwrite p/project= c/config= config-file= h/help
end

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

complete -c acceptarium -n "__fish_acceptarium_needs_command" -s p -l project -d 'Set project root path' -r -f -a "(__fish_complete_directories)"
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s c -l config -d 'Override a configuration value (can be passed multiple times)' -r
complete -c acceptarium -n "__fish_acceptarium_needs_command" -l config-file -d 'Path to a TOML config file, relative to project root' -r -F
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s n -l dry-run -d 'Run actions in dry run mode that checks everything but makes no changes'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -l no-dry-run
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s d -l dirty -d 'Allow changing Git state even when repository is dirty'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -l no-dirty
complete -c acceptarium -n "__fish_acceptarium_needs_command" -l overwrite -d 'Overwrite existing extracted transaction data'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -l no-overwrite
complete -c acceptarium -n "__fish_acceptarium_needs_command" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "add" -d 'Import an asset file and begin tracking via the configured storage'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "list" -d 'List known assets'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "process" -d 'Process an asset to extract data'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "dump" -d 'Output an asset to a structured data format'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "export" -d 'Output an asset to a PTA format'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "get" -d 'Get metadata for a specific asset by ID'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "set" -d 'Set metadata for a specific asset by ID'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "remove" -d 'Remove an asset and its metadata'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "run" -d 'Execute a script as a child process that inherits Acceptarium environment'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "status" -d 'Show status information about configuration, and state'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "tui" -d 'TUI for interactively reviewing and managing assets'
complete -c acceptarium -n "__fish_acceptarium_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s t -l commit -d 'Automatically commit imported asset to VCS tracker (if configured)'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -l no-commit
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s c -l copy -d 'Copy the source file from its current location into the configured data directory'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -l no-copy
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s r -l rename -d 'Rename source files using the internal asset ID when copying to data folder'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -l no-rename
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand add" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -l tracked -d 'View only assets currently tracked in VCS (if configured)'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -l no-tracked
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s a -l all -d 'Operate on all known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s p -l processed -d 'Operate only on assets have been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s u -l unprocessed -d 'Operate only on assets that have not been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand list" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -l processor -d 'Choose a specific image processor' -r -f -a "manual\t''
ocr\t''
vision\t''"
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -l extractor -d 'Choose a specific data extractor' -r -f -a "manual\t''
llm\t''
regex\t''
vision\t''"
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s a -l all -d 'Operate on all known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s p -l processed -d 'Operate only on assets have been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s u -l unprocessed -d 'Operate only on assets that have not been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand process" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s f -l format -d 'Data format to target' -r -f -a "hjson\t''
json\t''
toml\t''
yaml\t''
xml\t''"
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s a -l all -d 'Operate on all known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s p -l processed -d 'Operate only on assets have been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s u -l unprocessed -d 'Operate only on assets that have not been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand dump" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s f -l format -d 'Ledger format to target' -r -f -a "hledger\t''
ledger-cli\t''
beancount\t''
custom\t''"
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s a -l all -d 'Operate on all known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s p -l processed -d 'Operate only on assets have been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s u -l unprocessed -d 'Operate only on assets that have not been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand export" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand get" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand get" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand get" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand set" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand set" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand set" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s a -l all -d 'Operate on all known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s p -l processed -d 'Operate only on assets have been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s u -l unprocessed -d 'Operate only on assets that have not been marked as processed'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand remove" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand run" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand run" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand run" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand status" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand status" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand status" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand tui" -s v -l verbose -d 'Increase logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand tui" -s q -l quiet -d 'Decrease logging verbosity'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand tui" -s h -l help -d 'Print help'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "add" -d 'Import an asset file and begin tracking via the configured storage'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "list" -d 'List known assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "process" -d 'Process an asset to extract data'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "dump" -d 'Output an asset to a structured data format'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "export" -d 'Output an asset to a PTA format'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "get" -d 'Get metadata for a specific asset by ID'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "set" -d 'Set metadata for a specific asset by ID'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "remove" -d 'Remove an asset and its metadata'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "run" -d 'Execute a script as a child process that inherits Acceptarium environment'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "status" -d 'Show status information about configuration, and state'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "tui" -d 'TUI for interactively reviewing and managing assets'
complete -c acceptarium -n "__fish_acceptarium_using_subcommand help; and not __fish_seen_subcommand_from add list process dump export get set remove run status tui help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
