diff --git a/LICENSE b/LICENSE index 5ee4a0c..edeffdb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Aram Peres +Copyright (c) 2020-2021 Aram Peres Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b964161..a70e849 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,22 @@ A [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) client library for Rust. - Connect to `upsd`/`nut-server` using TCP -- Login with with username and password +- Login with username and password - List UPS devices - List variables for a UPS device ## ⚠️ Safety Goggles Required ⚠️ -Do not use this library with critical UPS devices. This library is in early development and I cannot -guarantee that it won't mess up your UPS configurations, and potentially cause catastrophic failure to your hardware. +Do not use this library with critical UPS devices. This library is in early development, and I cannot guarantee that it +won't mess up your UPS configurations, and potentially cause catastrophic failure to your hardware. Be careful and stay safe! ## Example -Check out the `examples` directory for more advanced examples. +The [rupsc](https://github.com/aramperes/nut-client-rs/tree/master/rupsc) +command-line utility is a clone of NUT's built-in [upsc](https://networkupstools.org/docs/man/upsc.html) command-line +utility, written using this library. ```rust use std::env; @@ -45,6 +47,7 @@ fn main() -> nut_client::Result<()> { let config = ConfigBuilder::new() .with_host(Host::Tcp(addr)) .with_auth(auth) + .with_debug(false) // Turn this on for debugging network chatter .build(); let mut conn = Connection::new(config)?; diff --git a/rupsc/Cargo.toml b/rupsc/Cargo.toml index 1612a21..6ef79ca 100644 --- a/rupsc/Cargo.toml +++ b/rupsc/Cargo.toml @@ -7,7 +7,7 @@ description = "A demo program to display UPS variables" categories = ["network-programming"] keywords = ["ups", "nut"] repository = "https://github.com/aramperes/nut-client-rs" -readme = "../README.md" +readme = "README.md" license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rupsc/LICENSE b/rupsc/LICENSE new file mode 100644 index 0000000..edeffdb --- /dev/null +++ b/rupsc/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020-2021 Aram Peres + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/rupsc/README.md b/rupsc/README.md new file mode 100644 index 0000000..145af59 --- /dev/null +++ b/rupsc/README.md @@ -0,0 +1,65 @@ +# rupsc + +[![crates.io](https://img.shields.io/crates/v/rupsc.svg)](https://crates.io/crates/rupsc) +[![Documentation](https://docs.rs/nut-client/badge.svg)](https://docs.rs/nut-client) +[![MIT licensed](https://img.shields.io/crates/l/rupsc.svg)](./LICENSE) +[![CI](https://github.com/aramperes/nut-client-rs/workflows/CI/badge.svg)](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI) + +A Rust clone of [upsc](https://networkupstools.org/docs/man/upsc.html), +the [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) demo program to display UPS variables. + +Written using the [nut-client](https://github.com/aramperes/nut-client-rs) crate. + +- Connect to `upsd`/`nut-server` using TCP +- List UPS devices +- List variables for a UPS device +- Get variable value of a UPS device +- List clients connected to a UPS device + +## Installation + +```bash +# Using cargo +cargo install rupsc + +# Or, build for other targets +# (make sure you install the appropriate toolchain & gcc linker) +cargo build --release --target armv7-unknown-linux-gnueabihf +cargo build --release --target aarch64-unknown-linux-gnu +cargo build --release --target arm-unknown-linux-gnueabihf +``` + +## Usage + +This is a clone of [`upsc`](https://networkupstools.org/docs/man/upsc.html), so the usage is the same: + +```bash +# Show usage +rupsc -h + +# List variables on UPS device "nutdev1" (assumes upsd running on 127.0.0.1:3493) +rupsc nutdev1 + +# List variables on UPS device "nutdev1" (remove upsd) +rupsc nutdev1@192.168.1.2:3493 + +# List available UPS devices +rupsc -l + +# List available UPS devices, with description +rupsc -L + +# List clients connected to UPS device "nutdev1" +rupsc -c nutdev1 +``` + +However, there are also some additions: + +```bash +# Enable network debugging (global flag). +ruspc -D +``` + +## Pronunciation + +> r-oopsie