diff --git a/bin/ipxe.pxe b/bin/ipxe.pxe new file mode 100644 index 0000000..d7f10f6 Binary files /dev/null and b/bin/ipxe.pxe differ diff --git a/src/cli.rs b/src/cli.rs index 4a8d76d..e7d93b1 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -49,4 +49,6 @@ pub enum Commands { Generate, /// Generate completions for your current shell ShellCompletions, + /// Test + Serve, } diff --git a/src/main.rs b/src/main.rs index b69af7f..890957b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,8 @@ use clap::{CommandFactory, Parser}; use clap_complete::{Shell, generate as generate_complete}; use crete::cluster::Cluster; use crete::environment::PathEnvironment; -use crete::{get_configs_path, get_repo_path, set_repo_path}; +use crete::tftp::ServerError; +use crete::{get_configs_path, get_repo_path, set_repo_path, tftp}; use minijinja::context; use thiserror::Error; @@ -16,6 +17,8 @@ use crate::cli::{Cli, Commands, GlobalOpts}; enum Error { #[error("No clusters where found")] NoClustersFound, + #[error("Server error: {0}")] + Server(#[from] ServerError), } fn run_command(mut command: Command) { @@ -79,7 +82,8 @@ fn generate(opts: &GlobalOpts) -> Result<(), Error> { Ok(()) } -fn main() -> Result<(), Error> { +#[tokio::main] +async fn main() -> Result<(), Error> { let cli = Cli::parse(); match cli.command { @@ -90,6 +94,14 @@ fn main() -> Result<(), Error> { "crete", &mut std::io::stdout(), ), + Commands::Serve => { + tftp::serve(|filename| match filename { + "ipxe.pxe" => Some(include_bytes!("../bin/ipxe.pxe").into()), + "test" => Some(vec![1, 2, 3, 4]), + _ => None, + }) + .await? + } }; Ok(()) diff --git a/test b/test new file mode 100644 index 0000000..82090ee --- /dev/null +++ b/test @@ -0,0 +1 @@ + \ No newline at end of file