login to start
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use bollard::Docker;
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
|
||||
use crate::{Config, DbPool};
|
||||
use crate::{Config, DbPool, dockermgr, models::Servers};
|
||||
|
||||
use std::fs;
|
||||
|
||||
@ -12,15 +13,15 @@ pub fn create_subcommand() -> Command {
|
||||
.arg(Arg::new("NAME").required(true))
|
||||
}
|
||||
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: DbPool) -> Result<(), String> {
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: &Docker) -> Result<(), String> {
|
||||
use crate::schema::servers::dsl::*;
|
||||
let server_name = arguments.get_one::<String>("NAME").unwrap();
|
||||
|
||||
let config = Config::load();
|
||||
|
||||
let conn = &mut pool.get().unwrap();
|
||||
|
||||
//todo stop the server if it's started
|
||||
|
||||
let _ = dockermgr::stop_server(docker, pool, server_name).await;
|
||||
|
||||
let deleted = diesel::delete(servers.filter(name.eq(server_name))).execute(conn).map_err(|_| "failed to delete from db".to_string())?;
|
||||
if deleted != 1 {
|
||||
|
||||
@ -15,7 +15,7 @@ pub fn create_subcommand() -> Command {
|
||||
.arg(Arg::new("NAME").required(true))
|
||||
}
|
||||
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: Docker) -> Result<(), String> {
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: &Docker) -> Result<(), String> {
|
||||
use schema::servers::dsl::*;
|
||||
let server_name = arguments.get_one::<String>("NAME").unwrap();
|
||||
dockermgr::start_server(&docker, pool, server_name).await?;
|
||||
|
||||
@ -12,7 +12,7 @@ pub fn create_subcommand() -> Command {
|
||||
.arg(Arg::new("NAME").required(true))
|
||||
}
|
||||
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: Docker) -> Result<(), String> {
|
||||
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: &Docker) -> Result<(), String> {
|
||||
let server_name = arguments.get_one::<String>("NAME").unwrap();
|
||||
println!("Stopping container");
|
||||
dockermgr::stop_server(&docker, pool, server_name).await?;
|
||||
|
||||
Reference in New Issue
Block a user