use workspaces to reduce dependencies (#7)
* use workspaces to reduce dependencies * bump version
This commit is contained in:
17
wakey-wake/Cargo.toml
Normal file
17
wakey-wake/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "wakey-wake"
|
||||
version = "0.2.2"
|
||||
|
||||
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
license = "MIT"
|
||||
repository = "https://github.com/LesnyRumcajs/wakey"
|
||||
|
||||
description = "Sample CLI tool for creating and sending Wake-on-LAN packets."
|
||||
keywords = ["wol", "wake-on-lan"]
|
||||
categories = ["network-programming"]
|
||||
|
||||
[dependencies]
|
||||
wakey = { path = "../wakey" }
|
||||
clap = { version = "3.1.18", features = ["derive"] }
|
||||
23
wakey-wake/src/main.rs
Normal file
23
wakey-wake/src/main.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(about = "WakeOnLan a device. https://github.com/LesnyRumcajs/wakey.git", long_about = None)]
|
||||
struct CmdArgs {
|
||||
/// mac address to send packet to
|
||||
#[clap(short, long)]
|
||||
mac: Option<String>,
|
||||
}
|
||||
fn main() {
|
||||
let args = CmdArgs::parse();
|
||||
if let Some(m) = args.mac {
|
||||
let sep = m.chars().find(|ch| *ch == ':' || *ch == '-').unwrap_or('/');
|
||||
let wol = wakey::WolPacket::from_string(&m, sep);
|
||||
if wol.send_magic().is_ok() {
|
||||
println!("sent the magic packet.");
|
||||
} else {
|
||||
println!("failed to send the magic packet.");
|
||||
}
|
||||
} else {
|
||||
println!("give mac address to wake up");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user