use workspaces to reduce dependencies (#7)

* use workspaces to reduce dependencies

* bump version
This commit is contained in:
Hubert
2022-06-26 12:13:12 +02:00
committed by GitHub
parent 08df76357c
commit 25ca3f4be6
6 changed files with 40 additions and 21 deletions

17
wakey-wake/Cargo.toml Normal file
View 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
View 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");
}
}