Skip to content

v.db.connect: End with error if both -p and -c are given #6263

@wenzeslaus

Description

@wenzeslaus

If both -p (print connection info) and -c (print columns instead of connection) are given to v.db.connect, -c is silently ignored. (Note that this was the case even before #6077.)

If anything, I would expect at least -c be accepted (as in "switch to printing/getter mode and print columns"). However, a better behavior to me is to expect exactly one flag, either connection printing mode or the completely different mode and that is the column printing mode.

So, -p and -c should be exclusive.

Since -pc isn't useful now (produced the same output as -p), making it an error won't break the API, so we can introduce the change anytime. (If -pc printed the columns, we would need to wait for v9.)

Current:

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -p
Vector map <bridges> is connected by:
layer <1/bridges> table <bridges> in database <.../sqlite/sqlite.db> through driver <sqlite> with key <cat>

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -c
INTEGER|cat
...
DOUBLE PRECISION|CO_
CHARACTER|CO_NAME

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -pc
Vector map <bridges> is connected by:
layer <1/bridges> table <bridges> in database <.../sqlite/sqlite.db> through driver <sqlite> with key <cat>

Expected:

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -p
Vector map <bridges> is connected by:
layer <1/bridges> table <bridges> in database <.../sqlite/sqlite.db> through driver <sqlite> with key <cat>

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -c
INTEGER|cat
...
DOUBLE PRECISION|CO_
CHARACTER|CO_NAME

$ grass --tmp-mapset .../nc_spm_08_grass7/ --exec v.db.connect bridges -pc
-p and -c are mutually exclusive

In C, use G_option_exclusive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CRelated code is in C

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions