mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
images and linking
This commit is contained in:
parent
da1e184e42
commit
06c0330de8
16 changed files with 1045 additions and 50 deletions
38
src/main.rs
38
src/main.rs
|
|
@ -1,5 +1,5 @@
|
|||
use crate::args::{HazeArgs, HazeCommand};
|
||||
use crate::cloud::{list, Cloud, CloudOptions};
|
||||
use crate::cloud::{get_by_filter, list, Cloud, CloudOptions};
|
||||
use crate::config::HazeConfig;
|
||||
use bollard::Docker;
|
||||
use color_eyre::{eyre::WrapErr, Report, Result};
|
||||
|
|
@ -18,11 +18,10 @@ async fn main() -> Result<()> {
|
|||
};
|
||||
|
||||
let args = HazeArgs::parse(std::env::args())?;
|
||||
dbg!(&args);
|
||||
|
||||
match args.command {
|
||||
HazeCommand::Clean => {
|
||||
let list = list(&mut docker, &config).await?;
|
||||
let list = list(&mut docker, None, &config).await?;
|
||||
for cloud in list {
|
||||
if let Err(e) = cloud.destroy(&mut docker).await {
|
||||
eprintln!("Error while removing cloud: {:#}", e);
|
||||
|
|
@ -30,20 +29,28 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
HazeCommand::List => {
|
||||
let list = list(&mut docker, &config).await?;
|
||||
let list = list(&mut docker, args.options.first().cloned(), &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
|
||||
)
|
||||
match cloud.ip {
|
||||
Some(ip) => println!(
|
||||
"Cloud {}, {}, {}, running on http://{}",
|
||||
cloud.id,
|
||||
cloud.php.name(),
|
||||
cloud.db.name(),
|
||||
ip
|
||||
),
|
||||
None => println!(
|
||||
"Cloud {}, {}, {}, not running",
|
||||
cloud.id,
|
||||
cloud.php.name(),
|
||||
cloud.db.name()
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
HazeCommand::Start => {
|
||||
|
|
@ -52,7 +59,14 @@ async fn main() -> Result<()> {
|
|||
return Err(Report::msg(format!("Unknown option {}", next)));
|
||||
}
|
||||
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||
println!("http://{}", cloud.ip);
|
||||
println!("http://{}", cloud.ip.unwrap());
|
||||
}
|
||||
HazeCommand::Logs => {
|
||||
let cloud = get_by_filter(&mut docker, args.options.first().cloned(), &config).await?;
|
||||
let logs = cloud.logs(&mut docker).await?;
|
||||
for log in logs {
|
||||
print!("{}", log);
|
||||
}
|
||||
}
|
||||
_ => todo!(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue