embed migrations, fix start, add stop
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/05/29 21:22:17 by tomoron #+# #+# */
|
||||
/* Updated: 2026/06/09 00:05:23 by tomoron ### ########.fr */
|
||||
/* Updated: 2026/06/09 17:04:32 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -34,6 +34,8 @@ pub type DbPool = Pool<ConnectionManager<SqliteConnection>>;
|
||||
|
||||
use bollard::Docker;
|
||||
|
||||
mod migrations;
|
||||
|
||||
fn get_connection_pool() -> DbPool {
|
||||
let database_url = "sqlite://".to_string() + &Config::load().config_path + "/db.sqlite";
|
||||
|
||||
@ -59,12 +61,16 @@ fn cli() -> Command {
|
||||
.subcommand(edit::create_subcommand())
|
||||
.subcommand(ls::create_subcommand())
|
||||
.subcommand(start::create_subcommand())
|
||||
.subcommand(stop::create_subcommand())
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> Result<(), String> {
|
||||
let arg = cli().get_matches();
|
||||
let pool = get_connection_pool();
|
||||
|
||||
migrations::run_migrations(&pool).map_err(|e| format!("Failed to run migrations : {}", e))?;
|
||||
|
||||
let docker = Docker::connect_with_defaults().expect("Failed to connect to local docker");
|
||||
|
||||
match arg.subcommand() {
|
||||
@ -75,6 +81,7 @@ async fn main() -> Result<(), String> {
|
||||
Some(("edit", sub_matches)) => { edit::subcommand(sub_matches, pool).await?; },
|
||||
|
||||
Some(("start", sub_matches)) => { start::subcommand(sub_matches, &pool, docker).await?; },
|
||||
Some(("stop", sub_matches)) => { stop::subcommand(sub_matches, &pool, docker).await?; },
|
||||
_ => {panic!("subcommand not implemented")}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user