mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
basic subcommands
This commit is contained in:
parent
d426b537b2
commit
da1e184e42
3 changed files with 192 additions and 41 deletions
48
src/main.rs
48
src/main.rs
|
|
@ -1,7 +1,8 @@
|
|||
use crate::cloud::{parse, Cloud, CloudOptions};
|
||||
use crate::args::{HazeArgs, HazeCommand};
|
||||
use crate::cloud::{list, Cloud, CloudOptions};
|
||||
use crate::config::HazeConfig;
|
||||
use bollard::Docker;
|
||||
use color_eyre::{eyre::WrapErr, Result};
|
||||
use color_eyre::{eyre::WrapErr, Report, Result};
|
||||
|
||||
mod args;
|
||||
mod cloud;
|
||||
|
|
@ -15,13 +16,46 @@ async fn main() -> Result<()> {
|
|||
sources_root: "/srv/http/owncloud".into(),
|
||||
work_dir: "/tmp/haze".into(),
|
||||
};
|
||||
let options = CloudOptions::default();
|
||||
|
||||
// let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||
// println!("{} running on http://{}", cloud.id, cloud.ip);
|
||||
let args = HazeArgs::parse(std::env::args())?;
|
||||
dbg!(&args);
|
||||
|
||||
let clouds = parse(&mut docker, &config).await?;
|
||||
dbg!(clouds);
|
||||
match args.command {
|
||||
HazeCommand::Clean => {
|
||||
let list = list(&mut docker, &config).await?;
|
||||
for cloud in list {
|
||||
if let Err(e) = cloud.destroy(&mut docker).await {
|
||||
eprintln!("Error while removing cloud: {:#}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
HazeCommand::List => {
|
||||
let list = list(&mut docker, &config).await?;
|
||||
for cloud in list {
|
||||
if let Some(filter) = &args.id {
|
||||
if !cloud.id.contains(filter.as_str()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
println!(
|
||||
"Cloud {}, {}, {}, running on http://{}",
|
||||
cloud.id,
|
||||
cloud.php.name(),
|
||||
cloud.db.name(),
|
||||
cloud.ip
|
||||
)
|
||||
}
|
||||
}
|
||||
HazeCommand::Start => {
|
||||
let (options, rest) = CloudOptions::parse(args.options)?;
|
||||
if let Some(next) = rest.first() {
|
||||
return Err(Report::msg(format!("Unknown option {}", next)));
|
||||
}
|
||||
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||
println!("http://{}", cloud.ip);
|
||||
}
|
||||
_ => todo!(),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue