# Fish completion for dasel

# Disable file completions by default
complete -c dasel -f

# Subcommands
complete -c dasel -n __fish_use_subcommand -a query -d '[default] Execute a query'
complete -c dasel -n __fish_use_subcommand -a version -d 'Print the version'
complete -c dasel -n __fish_use_subcommand -a interactive -d 'Start an interactive session (alpha)'
complete -c dasel -n __fish_use_subcommand -a completion -d 'Generate shell completion script'
complete -c dasel -n __fish_use_subcommand -a man -d 'Generate man page'

# Global flags
complete -c dasel -l help -s h -d 'Show context-sensitive help.'

# Query flags (default command, available at root level)
complete -c dasel -n '__fish_use_subcommand' -l var -d 'Variables to pass to the query. E.g. --var foo="bar" --var baz=json:file:./some/file.json'
complete -c dasel -n '__fish_use_subcommand' -l rw-flag -d 'Read/Write flag to customise parsing/output. Applies to read + write E.g. --rw-flag csv-delimiter=;'
complete -c dasel -n '__fish_use_subcommand' -l read-flag -d 'Reader flag to customise parsing. E.g. --read-flag xml-mode=structured'
complete -c dasel -n '__fish_use_subcommand' -l write-flag -d 'Writer flag to customise output. E.g. --write-flag csv-delimiter=;'
complete -c dasel -n '__fish_use_subcommand' -l in -s i -d 'The format of the input data.'
complete -c dasel -n '__fish_use_subcommand' -l out -s o -d 'The format of the output data.'
complete -c dasel -n '__fish_use_subcommand' -l root -d 'Return the root value.'
complete -c dasel -n '__fish_use_subcommand' -l compact -d 'Output in compact mode (no indentation/newlines).'
complete -c dasel -n '__fish_use_subcommand' -l unstable -d 'Allow access to potentially unstable features.'
complete -c dasel -n '__fish_use_subcommand' -l it -d 'Run in interactive mode (alpha).'
complete -c dasel -n '__fish_use_subcommand' -l config -s c -d 'Path to config file'

# Per-subcommand flags
complete -c dasel -n '__fish_seen_subcommand_from query' -l var -d 'Variables to pass to the query. E.g. --var foo="bar" --var baz=json:file:./some/file.json'
complete -c dasel -n '__fish_seen_subcommand_from query' -l rw-flag -d 'Read/Write flag to customise parsing/output. Applies to read + write E.g. --rw-flag csv-delimiter=;'
complete -c dasel -n '__fish_seen_subcommand_from query' -l read-flag -d 'Reader flag to customise parsing. E.g. --read-flag xml-mode=structured'
complete -c dasel -n '__fish_seen_subcommand_from query' -l write-flag -d 'Writer flag to customise output. E.g. --write-flag csv-delimiter=;'
complete -c dasel -n '__fish_seen_subcommand_from query' -l in -s i -d 'The format of the input data.'
complete -c dasel -n '__fish_seen_subcommand_from query' -l out -s o -d 'The format of the output data.'
complete -c dasel -n '__fish_seen_subcommand_from query' -l root -d 'Return the root value.'
complete -c dasel -n '__fish_seen_subcommand_from query' -l compact -d 'Output in compact mode (no indentation/newlines).'
complete -c dasel -n '__fish_seen_subcommand_from query' -l unstable -d 'Allow access to potentially unstable features.'
complete -c dasel -n '__fish_seen_subcommand_from query' -l it -d 'Run in interactive mode (alpha).'
complete -c dasel -n '__fish_seen_subcommand_from query' -l config -s c -d 'Path to config file'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l var -d 'Variables to pass to the query. E.g. --var foo="bar" --var baz=json:file:./some/file.json'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l rw-flag -d 'Read/Write flag to customise parsing/output. Applies to read + write E.g. --rw-flag csv-delimiter=;'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l read-flag -d 'Reader flag to customise parsing. E.g. --read-flag xml-mode=structured'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l write-flag -d 'Writer flag to customise output. E.g. --write-flag csv-delimiter=;'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l in -s i -d 'The format of the input data.'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l out -s o -d 'The format of the output data.'
complete -c dasel -n '__fish_seen_subcommand_from interactive' -l config -s c -d 'Path to config file'

# Format completions for --in/--out
complete -c dasel -l in -xa 'csv dasel hcl ini json kdl toml xml yaml'
complete -c dasel -l out -xa 'csv dasel hcl ini json kdl toml xml yaml'

# Shell completions for completion command
complete -c dasel -n '__fish_seen_subcommand_from completion' -xa 'bash zsh fish powershell'
