|
| 1 | +use crate::args::Server; |
1 | 2 | use crate::config::ComponentConfig; |
2 | 3 | use crate::config::ComponentConfigImportable; |
3 | 4 | use crate::config::ComponentLocation; |
@@ -26,6 +27,7 @@ use crate::config::toml::webhook::WebhookRoute; |
26 | 27 | use crate::config::toml::webhook::WebhookRouteVerified; |
27 | 28 | use crate::init; |
28 | 29 | use crate::init::Guard; |
| 30 | +use crate::project_dirs; |
29 | 31 | use anyhow::Context; |
30 | 32 | use anyhow::bail; |
31 | 33 | use chrono::DateTime; |
@@ -144,6 +146,55 @@ const GET_STATUS_POLLING_SLEEP: Duration = Duration::from_secs(1); |
144 | 146 |
|
145 | 147 | type ComponentSourceMap = hashbrown::HashMap<ComponentId, MatchableSourceMap>; |
146 | 148 |
|
| 149 | +impl Server { |
| 150 | + pub(crate) async fn run(self) -> Result<(), anyhow::Error> { |
| 151 | + match self { |
| 152 | + Server::Run { |
| 153 | + clean_sqlite_directory, |
| 154 | + clean_cache, |
| 155 | + clean_codegen_cache, |
| 156 | + config, |
| 157 | + } => { |
| 158 | + Box::pin(run( |
| 159 | + project_dirs(), |
| 160 | + BaseDirs::new(), |
| 161 | + config, |
| 162 | + RunParams { |
| 163 | + clean_sqlite_directory, |
| 164 | + clean_cache, |
| 165 | + clean_codegen_cache, |
| 166 | + }, |
| 167 | + )) |
| 168 | + .await |
| 169 | + } |
| 170 | + Server::GenerateConfig => { |
| 171 | + let obelisk_toml = PathBuf::from("obelisk.toml"); |
| 172 | + ConfigHolder::generate_default_config(&obelisk_toml).await?; |
| 173 | + println!("Generated {obelisk_toml:?}"); |
| 174 | + Ok(()) |
| 175 | + } |
| 176 | + Server::Verify { |
| 177 | + clean_cache, |
| 178 | + clean_codegen_cache, |
| 179 | + config, |
| 180 | + ignore_missing_env_vars, |
| 181 | + } => { |
| 182 | + verify( |
| 183 | + project_dirs(), |
| 184 | + BaseDirs::new(), |
| 185 | + config, |
| 186 | + VerifyParams { |
| 187 | + clean_cache, |
| 188 | + clean_codegen_cache, |
| 189 | + ignore_missing_env_vars, |
| 190 | + }, |
| 191 | + ) |
| 192 | + .await |
| 193 | + } |
| 194 | + } |
| 195 | + } |
| 196 | +} |
| 197 | + |
147 | 198 | #[derive(derive_more::Debug)] |
148 | 199 | struct GrpcServer { |
149 | 200 | #[debug(skip)] |
@@ -2543,8 +2594,8 @@ impl MatchableSourceMap { |
2543 | 2594 | #[cfg(test)] |
2544 | 2595 | mod tests { |
2545 | 2596 | use crate::{ |
2546 | | - ConfigHolder, |
2547 | 2597 | command::server::{ServerCompiledLinked, ServerVerified, VerifyParams}, |
| 2598 | + config::config_holder::ConfigHolder, |
2548 | 2599 | }; |
2549 | 2600 | use directories::BaseDirs; |
2550 | 2601 | use rstest::rstest; |
|
0 commit comments