feat: with extra churning repl thingy
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
8c41e1004c
commit
10eae9b36c
@ -13,7 +13,7 @@ struct Command {
|
|||||||
enum Commands {
|
enum Commands {
|
||||||
Bootstrap {
|
Bootstrap {
|
||||||
#[arg(env = "CHURN_AGENT", long)]
|
#[arg(env = "CHURN_AGENT", long)]
|
||||||
host: String,
|
agent: String,
|
||||||
|
|
||||||
#[arg(env = "CHURN_SERVER", long)]
|
#[arg(env = "CHURN_SERVER", long)]
|
||||||
server: String,
|
server: String,
|
||||||
@ -45,7 +45,7 @@ async fn handle_command(cmd: Command) -> anyhow::Result<()> {
|
|||||||
if let Some(cmd) = cmd.command {
|
if let Some(cmd) = cmd.command {
|
||||||
match cmd {
|
match cmd {
|
||||||
Commands::Bootstrap {
|
Commands::Bootstrap {
|
||||||
host,
|
agent,
|
||||||
server,
|
server,
|
||||||
server_token,
|
server_token,
|
||||||
} => todo!(),
|
} => todo!(),
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use dagger_rust::build::{RustVersion, SlimImage};
|
use dagger_rust::build::{RustVersion, SlimImage};
|
||||||
use dagger_sdk::Query;
|
use dagger_sdk::{Config, Query};
|
||||||
|
use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> eyre::Result<()> {
|
async fn main() -> eyre::Result<()> {
|
||||||
let client = dagger_sdk::connect().await?;
|
let mut config = Config::default();
|
||||||
|
config.logger = None;
|
||||||
|
|
||||||
|
println!("Building churning...");
|
||||||
|
|
||||||
|
let client = dagger_sdk::connect_opts(config).await?;
|
||||||
|
|
||||||
let agent = build_container(client.clone(), "churn-agent").await?;
|
let agent = build_container(client.clone(), "churn-agent").await?;
|
||||||
let agent = agent
|
let agent = agent
|
||||||
@ -35,6 +41,60 @@ async fn main() -> eyre::Result<()> {
|
|||||||
println!("{stderr}");
|
println!("{stderr}");
|
||||||
|
|
||||||
churning.exit_code().await?;
|
churning.exit_code().await?;
|
||||||
|
println!("Finished building churning...");
|
||||||
|
|
||||||
|
repl(churning).await?; //.with_entrypoint(vec!["churn"])).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn repl(container: dagger_sdk::Container) -> eyre::Result<()> {
|
||||||
|
let mut container = container;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let mut stdin = tokio::io::stdin();
|
||||||
|
let mut stdout = tokio::io::stdout();
|
||||||
|
|
||||||
|
stdout.write_all(b"> ").await?;
|
||||||
|
stdout.flush().await?;
|
||||||
|
|
||||||
|
let mut input = String::new();
|
||||||
|
|
||||||
|
let mut stdin = tokio::io::BufReader::new(stdin);
|
||||||
|
|
||||||
|
stdin.read_line(&mut input).await?;
|
||||||
|
|
||||||
|
let input = input.trim();
|
||||||
|
if input == "q" {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
container = container.with_exec(input.split(' ').collect());
|
||||||
|
|
||||||
|
match container.stdout().await {
|
||||||
|
Ok(stdout) => {
|
||||||
|
println!("{stdout}");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match container.stderr().await {
|
||||||
|
Ok(stderr) => {
|
||||||
|
println!("{stderr}");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match container.exit_code().await {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_e) => {
|
||||||
|
//eprintln!("encountred error: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user