# Test cases for the shell completion scripts.
#
# Format: <shells>|<command line, cursor is at the end>|<expected suggestions, separated by ";">
#
# <shells> is either "all" or a comma separated list of shells (bash, zsh, fish).
# Suggestions are compared as sorted logical values: descriptions are stripped and
# shell escaping is undone by the drivers.
#
# The expectations are what the user ends up with. In bash, ":" and "=" are part
# of COMP_WORDBREAKS, so readline only replaces what follows them: the driver
# prepends the part it keeps in place, as readline does.

# command names
all|app demo:|demo:file;demo:hello;demo:other;demo:special
all|app demo:h|demo:hello

# global option names
all|app --|--ansi;--help;--no-ansi;--no-interaction;--quiet;--silent;--verbose;--version

# the application called through a path instead of a name (%app% is replaced by
# the absolute path of the fixture)
all|%app% demo:|demo:file;demo:hello;demo:other;demo:special

# option names
all|app demo:hello --d|--dry-run
all|app demo:hello --f|--format

# option values
all|app demo:hello --format |json;xml;yaml
all|app demo:hello --format x|xml
all|app demo:hello -f |json;xml;yaml
# the "--option=value" form: bash and fish complete the whole word, so the
# suggestions keep the option, while zsh only completes the value (_describe -P)
bash,fish|app demo:hello --format=j|--format=json
zsh|app demo:hello --format=j|json
bash,fish|app demo:hello --env=|--env=dev;--env=prod;--env=test
zsh|app demo:hello --env=|dev;prod;test
# the option is only prepended while the cursor is inside the "--option=value" token
all|app demo:hello --format=json alic|alice

# an option with an optional value
all|app demo:hello --g|--greeting
all|app demo:hello --greeting |good morning;hello;hi
all|app demo:hello -g |good morning;hello;hi
bash,fish|app demo:hello --greeting=|--greeting=good morning;--greeting=hello;--greeting=hi
zsh|app demo:hello --greeting=|good morning;hello;hi
bash,fish|app demo:hello --greeting=h|--greeting=hello;--greeting=hi
zsh|app demo:hello --greeting=h|hello;hi

# an option accepting several values
all|app demo:hello --tag |beta;stable
all|app demo:hello --tag beta --tag |beta;stable
bash,fish|app demo:hello --tag=b|--tag=beta
zsh|app demo:hello --tag=b|beta

# argument values
all|app demo:hello |App\Entity\User;alice;bob;bob smith;ns:member
bash,zsh|app demo:hello a|alice
# fish matches anywhere in the value, "a" also matches "App\Entity\User"
fish|app demo:hello a|App\Entity\User;alice

# values containing a space
all|app demo:hello b|bob;bob smith

# values containing a colon
all|app demo:hello ns|ns:member
all|app demo:hello ns:|ns:member

# values containing a backslash (FQCN)
all|app demo:hello App|App\Entity\User

# quoted values
all|app demo:hello 'b|bob;bob smith
all|app demo:hello "b|bob;bob smith

# option after an argument, and flag without value followed by an argument
all|app demo:hello alice --format |json;xml;yaml
bash,zsh|app demo:hello --dry-run a|alice
fish|app demo:hello --dry-run a|App\Entity\User;alice

# values containing characters that are special for the shells. ";" cannot be
# used here, it is the separator of the expectations.
all|app demo:special x|x/y;x$y;x y;x"y;x'y;x`y;x*y;x&y;x\y;x(y);x!y;x#y;x=y
all|app demo:special |x/y;x$y;x y;x"y;x'y;x`y;x*y;x&y;x\y;x(y);x!y;x#y;x=y
all|app demo:special --value |y/z;y$z;y z;y"z;y'z
bash,fish|app demo:special --value=y|--value=y/z;--value=y$z;--value=y z;--value=y"z;--value=y'z
zsh|app demo:special --value=y|y/z;y$z;y z;y"z;y'z
all|app demo:special 'x|x/y;x$y;x y;x"y;x'y;x`y;x*y;x&y;x\y;x(y);x!y;x#y;x=y
all|app demo:special "x|x/y;x$y;x y;x"y;x'y;x`y;x*y;x&y;x\y;x(y);x!y;x#y;x=y

# paths and directories completed by the shell. The cases run in a directory
# containing "dir one/inner.txt", "dir2/x.twig", "file a.txt" and "file_b.yaml".
all|app demo:file fi|file a.txt;file_b.yaml
all|app demo:file d|dir one/;dir2/
all|app demo:file dir2/|dir2/x.twig
all|app demo:file file_b.yaml fi|file a.txt;file_b.yaml
all|app demo:file 'fi|file a.txt;file_b.yaml
# bash-completion quotes the word before listing the paths. bash only removes
# these quotes while readline completes a line, which the driver does not do.
zsh,fish|app demo:file |dir one/;dir2/;file a.txt;file_b.yaml
zsh,fish|app demo:file "fi|file a.txt;file_b.yaml
all|app demo:file --dir |dir one/;dir2/
all|app demo:file --dir d|dir one/;dir2/
all|app demo:file -d d|dir one/;dir2/
all|app demo:file --dir f|
bash,fish|app demo:file --dir=d|--dir=dir one/;--dir=dir2/
zsh|app demo:file --dir=d|dir one/;dir2/

# values completed along with the paths
all|app demo:file --config d|default;dir one/;dir2/
all|app demo:file --config b|bob smith
bash,fish|app demo:file --config bob\ s|bob smith
bash,fish|app demo:file --config=d|--config=default;--config=dir one/;--config=dir2/
zsh|app demo:file --config=d|default;dir one/;dir2/
