Crates.io | fortune-rs |
lib.rs | fortune-rs |
version | 0.1.0 |
source | src |
created_at | 2024-11-26 08:51:58.081166 |
updated_at | 2024-11-26 08:51:58.081166 |
description | A Rust implementation of the classic BSD fortune program |
homepage | https://github.com/twang2218/fortune-rs |
repository | https://github.com/twang2218/fortune-rs |
max_upload_size | |
id | 1461332 |
size | 90,546 |
A modern, feature-rich implementation of the classic BSD
fortune
program in Rust. This implementation aims to be a drop-in replacement for traditionalfortune
programs on Unix-like systems while maintaining compatibility with various fortune database formats.
# Clone the repository
git clone https://github.com/twang2218/fortune-rs.git
# Change into the directory
cd fortune-rs
# Build with optimizations
cargo build --release
The compiled binary will be available at
target/release/fortune
# Display a random fortune
fortune
# Display a random fortune from specific files or directories
fortune /path/to/fortune/file
# Display a random offensive fortune
fortune -o
Option | Description |
---|---|
-a |
Choose from all lists of maxims |
-c |
Show the cookie file source |
-f |
Print out the list of files |
-o |
Choose only offensive fortunes |
-s |
Display short fortunes only |
-l |
Display long fortunes only |
-n length |
Set length cutoff |
-m pattern |
Display matching fortunes |
-i |
Ignore case in pattern matching |
-w |
Wait based on message length |
-e |
Equal size file handling |
-D |
Enable debugging output |
# Pattern matching (case-insensitive)
fortune -i -m "pattern"
# Short fortunes only
fortune -s
# Show fortune sources
fortune -c
# List available fortune files
fortune -f
# Weighted selection
fortune 30% /path/to/fortunes1 70% /path/to/fortunes2
fortune-rs/
βββ src/
β βββ fortune.rs # Main implementation
β βββ strfile.rs # Database generator
β βββ metadata.rs # Metadata handling
βββ tests/
β βββ integration.rs # Integration tests
β βββ data/ # Test files
β βββ data2/ # Additional tests
βββ Cargo.toml # Project manifest
# Debug build
cargo build
# Release build with optimizations
cargo build --release
# Run all tests
cargo test
-m
)-i
)-l
, -s
, -n
)-f
)-o
)-e
)β Core Functionality
β Traditional Options
π Modern Enhancements
π Project Growth
We welcome contributions! Here's how you can help:
This project is licensed under the MIT License - see the LICENSE file for details.