Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve consistency in list-like CLI arguments #25854

Open
hiltontj opened this issue Jan 17, 2025 · 3 comments
Open

Improve consistency in list-like CLI arguments #25854

hiltontj opened this issue Jan 17, 2025 · 3 comments
Labels

Comments

@hiltontj
Copy link
Contributor

Problem statement

We don't have a standard convention for CLI args that accept lists of things.

In the influxdb3 create table command, we parse tags as space-separated list, e.g.,

influxdb3 create table --tags tag1 tag2 ...

In the influxdb3 create last_cache command, we parse key columns as comma-separated list, e.g.,

influxdb3 create last_cache --key-columns tag1,tag2

We should make these args accept a consistent form.

Proposed solution

I think we should use space-separated lists. This seems to be a more conventional use of clap (see how it is implemented in the create table command here) and CLI commands in general. For example,

ls dir1 dir2 file1 file2
rm file1.txt file2.txt file3.txt
cp file1.txt file2.txt /target/directory/
grep "pattern" file1.txt file2.txt file3.txt
# ... etc.

Therefore, we would need to update the following commands:

  • Distinct Cache (link)
  • Last Cache (link)
  • Generally, places where the SeparatedList type is used, which extends to Enterprise.

Alternatives considered

Use comma-separated lists. As per #25811, we had one internal user try to create a table with

influxdb3 create table cats --tags color,thickness ...

which leads to the creation of a table with a single tag "color,thickness" instead of two tags "color" and "thickness", and then writes to the database were not working for them because their line protocol assumed the latter.

Additional context

There may be an argument towards one solution or the other based on user expectation of tag/field naming conventions.

It is worth noting that both comma and space are allowed in tag names so long as they are escaped.

@pauldix
Copy link
Member

pauldix commented Jan 17, 2025

What would the arguments look like for test plugin and create trigger? Currently it's a comma separated list of key/value pairs, which are separated by =

@hiltontj
Copy link
Contributor Author

What would the arguments look like for test plugin and create trigger? Currently it's a comma separated list of key/value pairs, which are separated by =

Another similar example is the --fields argument in create table, which takes field names and their types, separated by :.

In that case it expects the key/value pair together, but still uses space-separation between key/value pairs, e.g.,

influxdb3 create table cats --database pets --fields name:utf8 weight:uint64

I suppose that is acceptable as well for the plugin CLIs?

@pauldix
Copy link
Member

pauldix commented Jan 17, 2025

Sure, I think that's acceptable for args as well? It would be good to have consistency here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants