| Crates.io | tnr |
| lib.rs | tnr |
| version | 0.2.0 |
| created_at | 2025-07-08 08:29:43.269283+00 |
| updated_at | 2025-07-08 08:41:16.419508+00 |
| description | A macOS notification library and CLI tool using terminal-notifier |
| homepage | https://github.com/naoto0822/tnr |
| repository | https://github.com/naoto0822/tnr |
| max_upload_size | |
| id | 1742198 |
| size | 22,150 |
A macOS notification library and CLI tool that provides a simple interface to send notifications using terminal-notifier.
This tool requires terminal-notifier to be installed on your macOS system:
brew install terminal-notifier
To use terminal-notifier, you need to configure macOS notification settings:
cargo install tnr
Add this to your Cargo.toml:
[dependencies]
tnr = "0.1.0"
# Basic notification
tnr --message "Hello, World!"
# Notification with title and type
tnr --title "Build Status" --message "Build completed successfully" --type success
# Notification with clickable URL
tnr --message "Check the results" --url "https://github.com"
# Error notification
tnr --message "Something went wrong" --type error
--title <TITLE>: Notification title--message <MESSAGE>: Notification message (required)--type <TYPE>: Notification type (error, warning, info, success)--url <URL>: URL to open when notification is clickeduse tnr::{Notify, Type};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Basic notification
Notify::new("Hello from Rust!")
.send()?;
// Notification with all options
Notify::new("Task completed successfully!")
.with_title("Build Status")
.with_type(Type::Success)
.with_url("https://github.com")
.send()?;
// Error notification
Notify::new("Something went wrong")
.with_type(Type::Error)
.send()?;
Ok(())
}
Type::Error - â with "Sosumi" soundType::Warning - â ī¸ with "Funk" soundType::Info - âšī¸ with "Glass" soundType::Success - â
with "Hero" soundNotifyThe main struct for creating and sending notifications.
new(message: impl Into<String>) -> Self - Create a new notification with a messagewith_title(self, title: impl Into<String>) -> Self - Set the notification titlewith_type(self, notification_type: Type) -> Self - Set the notification typewith_url(self, url: impl Into<String>) -> Self - Set a URL to open when clickedsend(&self) -> Result<(), TnrError> - Send the notificationTypeEnum representing different types of notifications with associated emojis and sounds.
The library uses TnrError enum for error handling:
TnrError::ExecutionFailed - terminal-notifier execution failedTnrError::CommandNotFound - terminal-notifier not found on systemSee the examples/ directory for more usage examples.
MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.