-
Notifications
You must be signed in to change notification settings - Fork 8
feat(config): add --no-confirm flag to automatically create config files #42
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
base: main
Are you sure you want to change the base?
Conversation
3f46eae to
2ffb217
Compare
|
Seems like a nice little feature. What happens if you run the same command with a config that already exists? Do it overwrite, prompt to overwrite, or fail? |
|
In my case the command finishes silently if the file already exists: $ ./ochami config cluster set --system --default c cluster.uri https://name:8443
/etc/ochami/config.yaml does not exist. Create it? [yn]:y
$ ./ochami config cluster set --system --default c cluster.uri https://name:8444No question on the second run. With $ rm -rf /etc/ochami/
$ ./ochami config --create cluster set --system --default c cluster.uri https://name:8443
$ ls /etc/ochami/
config.yaml
$ ./ochami config --create cluster set --system --default c cluster.uri https://name:8444No complaints on the second run if
It behaves as before. Completely recreating the file could also be expected, that is true. Initially I wanted to call the parameter |
|
I would think if a system config file already exists, I might want to go ahead and use it instead of overwriting it, especially since it may have been created previously by someone or something else. On the other hand, creating a prompt when you want to run everything automatically, seems counterintuitive in this particular context. Maybe it would make sense to include another flag if the intention is to overwrite regardless of the file exists in case you use the new file and have it fail or ignore by default? I'm not exactly sure what the best default behavior should be, but I can imagine a scenario where I'd only want the new file if it doesn't exist. Just something to think about. I also think having a |
|
@adrianreber Thank you very much for your contribution! I agree that having a way to non-interactively create the config file(s) will be useful for scripting environments as you've stated. However, we should think carefully about how we do this. Currently, there is already a On this, my thoughts are these:
Long story short, it probably only makes sense to have confirm flags on |
Add --no-confirm persistent flag to config command that automatically creates config files and parent directories without prompting for confirmation. Implementation details: - Add --no-confirm flag to config command as persistent flag - Update askToCreate function to accept noConfirm parameter - When noConfirm is true, askToCreate returns true without prompting - Simplify handleFileCreation to pass flag directly to askToCreate - Centralize all noConfirm logic within askToCreate function - Maintain backward compatibility with existing askToCreate behavior - Add test case for noConfirm functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Adrian Reber <areber@redhat.com>
2ffb217 to
0b77cb1
Compare
|
Thanks for the very detailed feedback. I tried to update the PR to have a flag called |
|
Apologies for the delay. It looks like you've implemented |
I am sorry, I don't get it. The flag For me For me To me it seems the combination of Before doing any further changes I hope to get some clarification from your side. |
|
Apologies, the following is sort of me thinking in writing, but hopefully it helps direct the discussion. 🙂 You bring up a good point and as I reconsider how to handle this, I realize that the current decision path for the prompting of the config file creation actually differs from that of the deletion commands. When
However, for config file creation, I think that the expected decision paths should be:
Ideally, I would like to re-use flags as much as possible to avoid having different flags that do identical/similar things. That said, I think we can rework both the config flag prompting mechanism and deletion prompting mechanism via the following generalized paths:
Applying this to the deletion example:
Applying this to the config creation example:
This allows us to reuse the same flags for commands that require yes/no prompts, subtracting as necessary, and (hopefully) reduces confusion. What are folks' thoughts on this? If this is feasible, we can change the config options in this PR and open a subsequent one for the deletion commands. |
|
Thinking about existing tools I've used.
How can we make the flag and the behavior least surprising? |
|
Using something intuitive while being succinct I think is the goal here. I generally prefer flags that are complementary (e.g. With scriptability in mind, my vision is that |
Add --no-confirm persistent flag to config command that automatically creates config files and parent directories without prompting for confirmation.
Implementation details:
🤖 Generated with Claude Code
This PR was required by lines from the OpenHPC OpenCHAMI recipe:
being able to run
looks nicer.