Nathan Fisher
06b88d2c24
- Split into workspace crates - Split into two binaries `corebox` and `hashbox` - Add `mount` crate to workspace to prepare for third binary `utilbox`
26 lines
700 B
Rust
26 lines
700 B
Rust
use super::Cmd;
|
|
use clap::Command;
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct Hostid;
|
|
|
|
impl Cmd for Hostid {
|
|
fn cli(&self) -> clap::Command {
|
|
Command::new("hostid")
|
|
.about("print the numeric identifier for the current host")
|
|
.author("Nathan Fisher")
|
|
.version(env!("CARGO_PKG_VERSION"))
|
|
}
|
|
|
|
fn run(&self, _matches: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> {
|
|
let hostid = unsafe { libc::gethostid() };
|
|
let hostid: String = format!("{hostid:x}").chars().skip(8).collect();
|
|
println!("{}", hostid);
|
|
Ok(())
|
|
}
|
|
|
|
fn path(&self) -> Option<shitbox::Path> {
|
|
Some(shitbox::Path::UsrBin)
|
|
}
|
|
}
|