-
Notifications
You must be signed in to change notification settings - Fork 48
Allow to manage multiple connectors when it apply #167
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jvenant, this looks great! Some minor comments/suggestions inline.
For example, I choose to add a --all option to process all connectors. But it could be a good idea to allow regexp or wildcard pattern instead (or both)
Good question; in general, I prefer if there's one way to acomplish a given task, not multiple ones. So if you foresee the need for selecting names using regexps, I wouldn't add --all
, because that'd be the same as --name-pattern=.*
. Given regexps are more flexible and "all" is just a special case, I'd probably go for the more powerful variant and add --name-pattern
.
For apply, I choose to not allow -n with multiple -f because it can be tricky to use otherwise. It might be too restrictive.
I think that's very sensible. Let's do it that way.
Just let me know if it's going the good way. I can adapt the implementation following recommendations.
And then apply the changes on all the other commands where it applies.
+1 I think you're on the right track. Thanks a lot!
Once we've converged on the options, the completion script should be updated as well (see README for instructions).
String contents; | ||
if (file.getName().equals("-")) { | ||
contents = readFromStdin(); | ||
} | ||
else if (!file.exists()) { | ||
spec.commandLine().getOut().println("Given file does not exist: " + file.toPath().toAbsolutePath()); | ||
return 1; | ||
throw new CommandLine.ExecutionException(spec.commandLine(), "Given file does not exist: " + file.toPath().toAbsolutePath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for raising an exception rather than returning a none 0 value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I asked to myself if it was a good idea.
The pragmatic answer is because the method return a String ^_^
But it can be manage of course
The underneath question is more global. It is about how to manage error when multiple connectors are processed.
- Should we run everything and then report all errors at the end ?
- Should we stop on first error
But for the readConfig
specific case, maybe it would be smarter to first read all the files and then only launch the apply process if evrything is ok.
What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for the readConfig specific case, maybe it would be smarter to first read all the files and then only launch the apply process if evrything is ok.
Yes, I think that makes sense. In general, I would
- Try to do as much validation/verification and abort if there was any validation failure, before starting mutating actions
- Abort after the first failure of a mutating action
for the regexp stuff : I was thinking about a |
I'm facing difficulties generating the completion. Picocli seems to (currently) requires an empty constructor. Which is not compatible with the constructror injection pattern used on some commands |
Yes, that's true. I thought I'd have added those default constructors to all the commands, but I may have missed some. Just add them in this case. They'll only be used for the completion generation, otherwise the inject-ed constructors are used. |
So would -e take the pattern then (which I think grep is doing)? Or would -e be a "switch" that impacts how the --name value is interpreted? Can you share the entire command invocation perhaps? |
Good point : Not exactly like grep then. I see it more like a switch ; It could be confusing as the user may consider the
|
I'll do |
I made a commit taking in account your feedback. Currently it is a switch -e on pause, but I can change to something else. I redesign the patch for multiple files on Apply. I think it is more robust like this, but it involve more changes in the code that I was expecting. So don't hesitate to tell me if you're not OK with some of my changes. I can adapt. I'll apply the changes on others commands once we are OK with this ones |
Cool, I think that's a good approach. I was leaning towards My only question would be why "-e"? I.e. what does "e" it stand for, "expression"? How about using "-r"/"--reg-exp" for easier memorization? Btw. on "--reg-exp" vs. "--regexp", it probably should be the former, as we use the dash in multi-word option names (e.g. see SetContextCommand). |
Thanks, it all LGTM and I think we've achieved agreement on the way forward. Apart from bringing regexp support to all commands taking a connector or task name, one other thing to do would be updating the list of commands in the README (it's the out of kcctl without any commands). Ah, and at the end, ideally everything should be squashed into one commit, using a suitable gitmoji emoji and the issue key as prefix (see other commits in the history for examples). Thanks again! |
Patch already have a |
I currently setup |
Ah yes, I see. So looks like we should use |
Changed to Any idea ? |
Interesting, I haven't seen that one before. Are you using Java 17 to build
kcctl=
… Message ID: ***@***.***>
|
Yes java 17. It works without my commit. |
It's related to the ApplyConnector record I added in ApplyCommand. So : I think we're good... |
Hey @jvenant, so this LGTM, merging. Thanks a lot for this very nice piece of work! |
Fixes #107
This is a base of discussion about the best way to manage multiples connectors in one command
For example, I choose to add a
--all
option to process all connectors. But it could be a good idea to allow regexp or wildcard pattern instead (or both)For apply, I choose to not allow
-n
with multiple-f
because it can be tricky to use otherwise. It might be too restrictive.Just let me know if it's going the good way. I can adapt the implementation following recommendations.
And then apply the changes on all the other commands where it applies.