Skip to content

Commit

Permalink
Use seahorse for actual CLI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed May 16, 2024
1 parent e7031bc commit 75e4fa4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 231 deletions.
207 changes: 4 additions & 203 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ectool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
crosec = { version = "0.1.0", path = "../crosec" }
color-eyre = "0.6.2"
seahorse = "2.2.0"
57 changes: 30 additions & 27 deletions ectool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
use color_eyre::eyre::Result;
use std::env;
use seahorse::{App, Command};
use crosec::commands::{
get_chip_info::ec_cmd_get_chip_info, hello::ec_cmd_hello, version::ec_cmd_version,
};

fn main() -> Result<()> {
color_eyre::install()?;
fn main() {
let args: Vec<String> = env::args().collect();
let app = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.command(Command::new("hello").action(|_c| {
let status = ec_cmd_hello().unwrap();
if status {
println!("EC says hello!");
} else {
println!("EC did not say hello :(");
}
}))
.command(Command::new("version").action(|_c| {
let (ro_ver, rw_ver, firmware_copy, build_info, tool_version) = ec_cmd_version().unwrap();
println!("RO version: {ro_ver}");
println!("RW version: {rw_ver}");
println!("Firmware copy: {firmware_copy}");
println!("Build info: {build_info}");
println!("Tool version: {tool_version}");
}))
.command(Command::new("chipinfo").action(|_c| {
let (vendor, name, revision) = ec_cmd_get_chip_info().unwrap();
println!("Chip info:");
println!(" vendor: {vendor}");
println!(" name: {name}");
println!(" revision: {revision}");
}));

println!("Hello command");
let status = ec_cmd_hello()?;
if status {
println!("EC says hello!");
} else {
println!("EC did not say hello :(");
}

println!("Version command");
let (ro_ver, rw_ver, firmware_copy, build_info, tool_version) = ec_cmd_version()?;
println!("RO version: {ro_ver}");
println!("RW version: {rw_ver}");
println!("Firmware copy: {firmware_copy}");
println!("Build info: {build_info}");
println!("Tool version: {tool_version}");

println!("Chip info command");
let (vendor, name, revision) = ec_cmd_get_chip_info()?;
println!("Chip info:");
println!(" vendor: {vendor}");
println!(" name: {name}");
println!(" revision: {revision}");

Ok(())
app.run(args);
}

0 comments on commit 75e4fa4

Please sign in to comment.