I'd like to write completion for a program taking --dsn=<database-specification>
option where database specification is of the form backend://something-else
and where "backend" can take one of several predefined values, such as postgresql
, odbc
or sqlite3
and I want to complete the rest of the option differently depending on which value is chosen.
I know how to complete the backend using something like
_arguments '--dsn[database connection string]:DSN:(sqlite3\:// postgresql\://)' ...
but I don't know how to provide the backend-specific completions later. I thought that I should use $state
, but I don't see how to set it to the different values depending on the backend chosen.
Could someone please explain how to do it or, maybe, point me to a different way of doing what I want?