mirror of
https://github.com/quantum5/ntfy-run.git
synced 2025-04-24 13:41:58 -04:00
Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
|
2109cd45aa | ||
|
a5e9f7e6fe | ||
|
4ef2eab3db | ||
|
6faafdd7ae | ||
|
58f0ba9952 | ||
|
7e74fc8888 |
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -592,7 +592,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ntfy-run"
|
name = "ntfy-run"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
|
14
Cargo.toml
14
Cargo.toml
|
@ -1,7 +1,19 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ntfy-run"
|
name = "ntfy-run"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
authors = ["Quantum <me@quantum5.ca>"]
|
||||||
|
description = "ntfy-run is a tool to run a command, capture its output, and send it to a ntfy server."
|
||||||
|
readme = "README.md"
|
||||||
|
homepage = "https://github.com/quantum5/ntfy-run"
|
||||||
|
repository = "https://github.com/quantum5/ntfy-run"
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
keywords = ["ntfy", "cron", "notifications", "utility"]
|
||||||
|
categories = ["command-line-interface"]
|
||||||
|
|
||||||
|
exclude = [
|
||||||
|
".github/*"
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.20", features = ["derive", "env"] }
|
clap = { version = "4.5.20", features = ["derive", "env"] }
|
||||||
|
|
|
@ -16,7 +16,13 @@ sudo wget https://github.com/quantum5/ntfy-run/releases/latest/download/ntfy-run
|
||||||
sudo chmod a+x /usr/local/bin/ntfy-run
|
sudo chmod a+x /usr/local/bin/ntfy-run
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, build it yourself:
|
You can also install the latest release with `cargo`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo install ntfy-run
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, you can build the latest Git version yourself:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/quantum5/ntfy-run.git
|
git clone https://github.com/quantum5/ntfy-run.git
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -1,13 +1,13 @@
|
||||||
use crate::runner::CaptureError;
|
use crate::runner::{CaptureError, CapturedOutput};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use runner::CapturedOutput;
|
use std::process::exit;
|
||||||
|
|
||||||
mod quote;
|
mod quote;
|
||||||
mod runner;
|
mod runner;
|
||||||
mod tap_stream;
|
mod tap_stream;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
/// Tool to run a command, capture its output, and send it to ntfy.
|
#[command(version, about)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// URL of the ntfy server and topic, e.g. https://ntfy.sh/topic
|
/// URL of the ntfy server and topic, e.g. https://ntfy.sh/topic
|
||||||
#[arg(short = 'n', long = "ntfy-url", env = "NTFY_URL", alias = "url")]
|
#[arg(short = 'n', long = "ntfy-url", env = "NTFY_URL", alias = "url")]
|
||||||
|
@ -210,7 +210,13 @@ async fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
match request.send().await.and_then(|r| r.error_for_status()) {
|
match request.send().await.and_then(|r| r.error_for_status()) {
|
||||||
Ok(_) => (),
|
Ok(_) => exit(match status {
|
||||||
Err(error) => eprintln!("Failed to send request to ntfy: {}", error),
|
Some(code) => code.code().unwrap_or(255),
|
||||||
|
None => 255,
|
||||||
|
}),
|
||||||
|
Err(error) => {
|
||||||
|
eprintln!("Failed to send request to ntfy: {}", error);
|
||||||
|
exit(37)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::tap_stream::{ReadOrWrite, TapStream};
|
use crate::tap_stream::{ReadOrWrite, TapStream};
|
||||||
use std::process::{ExitStatus, Stdio};
|
use std::process::{ExitStatus, Stdio};
|
||||||
use tokio::process::Command;
|
use tokio::{io, process::Command, select};
|
||||||
use tokio::{io, select};
|
|
||||||
|
|
||||||
pub enum CaptureError {
|
pub enum CaptureError {
|
||||||
Spawn(io::Error),
|
Spawn(io::Error),
|
||||||
|
|
Loading…
Reference in a new issue