这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(cli): add "save-config" subcommand to store configuration #244

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

appleboy
Copy link
Contributor

@appleboy appleboy commented May 17, 2025

  • Added a new save-config subcommand to save the current configuration to the default config path.
  • Implemented the WriteConfigurationFile method to handle writing the configuration file.
  • Introduced the expandConfigPath helper function to process {CONFIG} and {HOME} placeholders in config paths.
  • Enhanced error handling and reporting for reading and writing configuration files.
  • Updated the Options struct to prevent certain fields (TracePath, ToolConfigPaths) from being marshaled into the config file.
  • Refactored LoadConfigurationFile to use expandConfigPath and provide clearer error messages.
  • Simplified the execution logic of the root command.

Copy link
Member

@droot droot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Change is looking food except that it needs to be rebased.

- Add SaveConfig option to enable saving the current configuration to the default config path
- Implement WriteConfigurationFile method to write configuration when SaveConfig is set
- Refactor configuration file path handling with expandConfigPath helper
- Improve error reporting when reading and writing configuration files
- Add --save-config CLI flag

Signed-off-by: appleboy <appleboy.tw@gmail.com>
@appleboy
Copy link
Contributor Author

@droot See 3e4b36d

appleboy added 4 commits May 31, 2025 10:09
- Use filepath.Join to construct default config paths for better cross-platform compatibility
- Split config path tokens based on the OS path separator instead of hardcoding "/"

Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Refactor expandConfigPath to use string replacement instead of splitting paths.
- Improve error messages when expanding {CONFIG} or {HOME} placeholders.
- Ensure file paths are cleaned with filepath.Clean before reading configuration files.

Signed-off-by: appleboy <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
@appleboy
Copy link
Contributor Author

appleboy commented May 31, 2025

@droot All Done. Please help review again.

@appleboy appleboy changed the title feat: add option to save and manage configuration files via CLI feat(cli): add option to save and manage configuration files May 31, 2025
@appleboy appleboy changed the title feat(cli): add option to save and manage configuration files feat(cli): add subcommand to save and manage configuration files May 31, 2025
@appleboy appleboy changed the title feat(cli): add subcommand to save and manage configuration files feat(cli): add save-config command May 31, 2025
@appleboy appleboy changed the title feat(cli): add save-config command feat(cli): add store configuration sub command save-config May 31, 2025
@appleboy appleboy changed the title feat(cli): add store configuration sub command save-config feat(cli): add store configuration sub command save-config May 31, 2025
@appleboy appleboy changed the title feat(cli): add store configuration sub command save-config feat(cli): add "save-config" subcommand to store configuration May 31, 2025
@droot
Copy link
Member

droot commented Jun 2, 2025

@appleboy We recently added support for mcp and custom tools and that introduced two more configuration files that kubectl-ai takes input from. We are thinking of re-factoring the config stuff so that we can unify the config for kubectl-ai, custom-tools and mcp.
So want to hold this PR for now til that refactor is done because being able to save adds another feature to consider.

We will get the PR in but there will be delay, hope you understand. Thank you!

@appleboy
Copy link
Contributor Author

appleboy commented Jun 3, 2025

@droot Sounds Good. Thank you for getting back to me.

@appleboy
Copy link
Contributor Author

appleboy commented Jul 3, 2025

@droot May I continue working on this pull request?

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

Successfully merging this pull request may close these issues.

2 participants