Closed SteadBytes closed 3 years ago
kcl actually has this ability! But it's not as obvious as kcl topic list
. The current command to do this is kcl metadata -t
, and you can specify individual topics as additional arguments (vs. the default of all topics).
I could potentially add an alias here / add topic list directly. The reason I went with metadata is that (as you saw) the only way to list topics is through a metadata request, which also returns a bunch of other useful information -- so kcl metadata
has flags to opt in to print which information you want (I usually do kcl metadata -tib
).
What do you think of this? It may still be worth it to have kcl topic list
, though.
Woops! Apologies for missing that - I see now from kcl metadata -h
:facepalm:
I don't disagree with your reasoning around using kcl metadata
for this, however could providing kcl topic list
as essentially an alias for kcl metadata -t
be useful? It seems more intuitive, at least in my opinion, to have create
, list
and delete
actions together.
That said, the main reason for the issue was to have the functionality at all. Perhaps, if nothing else, including some examples of kcl metadata
in the README example usages would help expose the functionality to users?
I think kcl topic list
may be a fine addition! Would you like to create a PR, or I could do it?
Also README examples may be good too!
I'm happy to put up a PR π Do you think kcl topic list
should literally be an alias for kcl metadata -t
? e.g. directly run metadata.Command
with "-t"
in the args list - something like:
func topicListCommand(cl *client.Client) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"l"},
Short: "List all topics",
Long: "List all topics (alias for metadata -t)",
Run: func(_ *cobra.Command, _ []string) {
cmd := metadata.Command(cl)
cmd.SetArgs([]string{"-t"})
cmd.Execute()
},
}
return cmd
}
Or is it worth pulling that part of the metadata command out to be shared?
I didn't think it'd be that easy, that looks like a great choice. I'm open for whatever is easiest.
It's probably also worth it to include support for the -d
flag for detailed output, but I think that could just be if detailed { cmd.SetArgs... }
.
What do you think? Otherwise I'm onboard with that.
For aliases I usually add ls
for list ones, but l
can work too -- if you want to add both?
Great!
It's probably also worth it to include support for the
-d
flag for detailed output
Yes the -d
flag is definitely a useful addition.
For aliases I usually add ls for list ones, but l can work too -- if you want to add both?
If ls
is the common pattern then it's probably best to stick with that π
I'll get a PR up tomorrow morning βΊοΈ
It's often useful to be able to list all available topics.
kcl
could support this with akcl topic list
command:It could also include optional internal topic filtering. What do you think?
There's some potential complication with handling Kafka versions <
0.10.0
due tokmsg.MetadataRequest.Topics
takingnil
or and empty slice to indicate all topics but the gist of the command is something like:Happy to submit a PR for implementation if desired π