Prepare release v0.3 (#19)

* cleanup the wakey binary

* add changelog

* update versions

* update readme
This commit is contained in:
Hubert 2023-01-06 22:01:34 +01:00 committed by GitHub
parent 23f9a53a26
commit 0868354063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 23 deletions

19
CHANGELOG.md Normal file
View File

@ -0,0 +1,19 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.3.0] - 2023-01-06
### Added
- this changelog :)
### Changed
- refactored the interface and internals a bit. In short, the library should no longer panic on any errors and should return a sane `Result` so it can be handled by the crate user.
- made methods `WolPacket::from_string` and `WolPacket::mac_to_byte` more flexible by making the `data` an `AsRef<str>`.
- `wakey-wake` no longer needs an `-m` or `--mac` flag. The adress is now a positional argument so just call the binary with the appropriate address.

View File

@ -11,11 +11,11 @@ Library for managing Wake-on-LAN packets. It supports:
From string representation of MAC address and using defaults when broadcasting:
```rust
let wol = wakey::WolPacket::from_string("01:02:03:04:05:06", ':');
let wol = wakey::WolPacket::from_string(&mac_adress, sep)?;
if wol.send_magic().is_ok() {
println!("Sent the magic packet!");
println!("Sent the magic packet.");
} else {
println!("Failed to send the magic packet!");
println!("Failed to send the magic packet.");
}
```
@ -23,15 +23,15 @@ Packets can also be constructed with raw bytes and sent from / to custom address
```rust
use std::net::SocketAddr;
let wol = wakey::WolPacket::from_bytes(&[0x00, 0x01, 0x02, 0x03, 0x04, 0x05]);
let wol = wakey::WolPacket::from_bytes(&[0x00, 0x01, 0x02, 0x03, 0x04, 0x05])?;
let src = SocketAddr::from(([0,0,0,0], 0));
let dst = SocketAddr::from(([255,255,255,255], 9));
wol.send_magic_to(src, dst);
wol.send_magic_to(src, dst)?;
```
## Included binary
```
cargo run --bin wakey-wake -m 00:11:22:33:44:55
cargo run --bin wakey-wake 00:11:22:33:44:55
```

View File

@ -1,6 +1,6 @@
[package]
name = "wakey-wake"
version = "0.2.2"
version = "0.3.0"
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
edition = "2021"
@ -14,4 +14,4 @@ categories = ["network-programming"]
[dependencies]
wakey = { path = "../wakey" }
clap = { version = "4.0.15", features = ["derive"] }
clap = { version = "4.0", features = ["derive"] }

View File

@ -1,25 +1,24 @@
use clap::Parser;
#[derive(Parser)]
#[clap(about = "WakeOnLan a device. https://github.com/LesnyRumcajs/wakey.git", long_about = None)]
#[clap(author, version, about, long_about = None)]
struct CmdArgs {
/// mac address to send packet to
#[clap(short, long)]
mac: Option<String>,
/// MAC address to send packet to. Should be in format AA:BB:CC:DD:EE:FF, AA-BB-CC-DD-EE-FF or
/// AA/BB/CC/DD/EE/FF.
mac_address: String,
}
fn main() -> wakey::Result<()> {
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.");
}
let mac_adress = CmdArgs::parse().mac_address;
let sep = mac_adress
.chars()
.find(|ch| *ch == ':' || *ch == '-' || *ch == '/')
.expect("Invalid MAC address format. Please use one of the separators: [:, -, /]");
let wol = wakey::WolPacket::from_string(&mac_adress, sep)?;
if wol.send_magic().is_ok() {
println!("Sent the magic packet.");
} else {
println!("give mac address to wake up");
println!("Failed to send the magic packet.");
}
Ok(())

View File

@ -1,6 +1,6 @@
[package]
name = "wakey"
version = "0.2.2"
version = "0.3.0"
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
edition = "2021"