add try_load and try_print stubs + cmds
This commit is contained in:
parent
64e9a2eced
commit
c55715fd3a
2 changed files with 25 additions and 0 deletions
|
|
@ -12,3 +12,4 @@ serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde_json = "1.0.114"
|
serde_json = "1.0.114"
|
||||||
thiserror = "1.0.58"
|
thiserror = "1.0.58"
|
||||||
toml = "0.8.11"
|
toml = "0.8.11"
|
||||||
|
uuid = { version = "1.8.0", features = ["v8"] }
|
||||||
|
|
|
||||||
24
src/main.rs
24
src/main.rs
|
|
@ -3,6 +3,7 @@ use std::fs;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
@ -53,6 +54,16 @@ impl Prusa {
|
||||||
Ok(info)
|
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> {
|
fn print_info(&self) -> Result<(), Error> {
|
||||||
let info = self.get_info()?;
|
let info = self.get_info()?;
|
||||||
println!("\n--------------------");
|
println!("\n--------------------");
|
||||||
|
|
@ -76,6 +87,13 @@ struct Cli {
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Command {
|
enum Command {
|
||||||
Info,
|
Info,
|
||||||
|
Load {
|
||||||
|
#[arg(short, long)]
|
||||||
|
filepath: String,
|
||||||
|
},
|
||||||
|
Print {
|
||||||
|
file_id: Uuid,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
@ -113,6 +131,12 @@ fn main() -> Result<(), Error> {
|
||||||
let prusa = Prusa::new(&config.printer.api_key, &config.printer.ip_addr);
|
let prusa = Prusa::new(&config.printer.api_key, &config.printer.ip_addr);
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Command::Info => prusa.print_info()?,
|
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")
|
_ => println!("Unrecognized printer type")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue