feature/smbcloud-deploy
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | crate::config::Config, |
| 3 | smbcloud_model::error_codes::{ErrorCode, ErrorResponse}, |
| 4 | std::{fs, path::Path}, |
| 5 | }; |
| 6 | |
| 7 | pub fn write_config(repo_path: &str, config: Config) -> Result<(), ErrorResponse> { |
| 8 | // Ensure .smb directory exists |
| 9 | let smb_dir = Path::new(&repo_path).join(".smb"); |
| 10 | if !smb_dir.exists() { |
| 11 | fs::create_dir(smb_dir).map_err(|_| ErrorResponse::Error { |
| 12 | error_code: ErrorCode::MissingConfig, |
| 13 | message: ErrorCode::MissingConfig.message(None).to_string(), |
| 14 | })?; |
| 15 | } |
| 16 | |
| 17 | // Write config to .smb/config.toml |
| 18 | let config_toml = toml::to_string(&config).map_err(|_| ErrorResponse::Error { |
| 19 | error_code: ErrorCode::MissingConfig, |
| 20 | message: ErrorCode::MissingConfig.message(None).to_string(), |
| 21 | })?; |
| 22 | |
| 23 | fs::write(".smb/config.toml", config_toml).map_err(|_| ErrorResponse::Error { |
| 24 | error_code: ErrorCode::MissingConfig, |
| 25 | message: ErrorCode::MissingConfig.message(None).to_string(), |
| 26 | })?; |
| 27 | |
| 28 | Ok(()) |
| 29 | } |