oxyde_cloud_cli/commands/init/
mod.rs1use cliclack::log::remark;
2use cliclack::{intro, outro};
3use std::path::PathBuf;
4use tera::Context;
5
6mod app_slug;
7mod error;
8mod team;
9
10use crate::commands::deploy_config::init_deploy_config;
11use crate::commands::init::app_slug::input_app_slug;
12use crate::commands::init::team::input_team_slug;
13use crate::commands::TEMPLATES;
14
15pub use error::*;
16
17pub async fn init(
18 app_slug: Option<String>,
19 team_slug: Option<String>,
20 config_file: PathBuf,
21) -> Result<(), Error> {
22 intro("Oxyde Cloud app init")?;
23
24 let team_slug = match team_slug {
25 Some(team_slug) => {
26 remark(&format!("Team provided: {}", team_slug))?;
27 team_slug
28 }
29 None => input_team_slug().await?,
30 };
31
32 let app_slug = match app_slug {
33 Some(slug) => {
34 remark(&format!("App slug provided: {}", slug))?;
35 slug
36 }
37 None => input_app_slug(&team_slug).await?,
38 };
39
40 let mut context = Context::new();
41 context.insert("app_slug", &app_slug);
42 let config_str = TEMPLATES.render("oxyde-cloud.toml", &context)?;
43
44 std::fs::write(&config_file, config_str)?;
45
46 outro(&format!("Created config file: {}\n", config_file.display()))?;
47
48 init_deploy_config()?;
49
50 Ok(())
51}