add try_load and try_print stubs + cmds

This commit is contained in:
sigil-03 2024-03-18 20:08:44 -06:00
parent 64e9a2eced
commit c55715fd3a
2 changed files with 25 additions and 0 deletions

View file

@ -12,3 +12,4 @@ serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
thiserror = "1.0.58"
toml = "0.8.11"
uuid = { version = "1.8.0", features = ["v8"] }

View file

@ -3,6 +3,7 @@ use std::fs;
use thiserror::Error;
use serde::Deserialize;
use reqwest::blocking::Client;
use uuid::Uuid;
#[derive(Deserialize, Debug)]
@ -53,6 +54,16 @@ impl Prusa {
Ok(info)
}
fn try_load_file(&self, _filepath: &str) -> Result<Uuid, Error> {
todo!("implement try_load_file")
}
fn try_print_file(&self, _id: &Uuid) -> Result<(), Error> {
todo!("implement try_print_file")
}
// TODO: poorly named, should be something else so as not to confuse with print operations
fn print_info(&self) -> Result<(), Error> {
let info = self.get_info()?;
println!("\n--------------------");
@ -76,6 +87,13 @@ struct Cli {
#[derive(Subcommand)]
enum Command {
Info,
Load {
#[arg(short, long)]
filepath: String,
},
Print {
file_id: Uuid,
},
}
#[derive(Deserialize, Debug)]
@ -113,6 +131,12 @@ fn main() -> Result<(), Error> {
let prusa = Prusa::new(&config.printer.api_key, &config.printer.ip_addr);
match cli.command {
Command::Info => prusa.print_info()?,
// Should generate UUID for the filename:
Command::Load {filepath} => {
let uuid = prusa.try_load_file(&filepath)?;
println!("Loaded as UUID:\n{uuid}");
},
Command::Print {file_id} => prusa.try_print_file(&file_id)?,
}
}
_ => println!("Unrecognized printer type")