Skip to content

Command-line tool that prints random fortune entries. rust version of fortune

Notifications You must be signed in to change notification settings

zuisong/rs-fortune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rs-fortune

🇨🇳 中文版 Readme

rs-fortune is a simple Rust command-line tool that prints random fortune entries.

Installation

  • Download and install from the Release page

  • Install via Cargo:

    cargo install --git https://github.com/zuisong/rs-fortune
  • MacOS users can install via Homebrew:

    brew install zuisong/tap/rs-fortune

Usage

A rust version of fortune

Usage: rs-fortune [FORTUNE_FILE] [COMMAND]

Commands:
  completions  Generate tab-completion scripts for your shell
  help         Print this message or the help of the given subcommand(s)

Arguments:
  [FORTUNE_FILE]  The fortune cookie file path [env: FORTUNE_FILE=/Users/chen/.config/fish/kindle.txt]

Options:
  -h, --help     Print help
  -V, --version  Print version

<fortune file> is a text file containing fortune entries, separated by % on a line of its own.

rs-fortune also supports reading <fortune file> path from the FORTUNE_FILE environment variable:

FORTUNE_FILE=fortunes.txt rs-fortune

If both command-line arguments and environment variables are provided, the command-line arguments take precedence.

For example, if a fortune file named fortunes.txt contains:

Fortune favors the bold.
%
The early bird gets the worm.
%
Slow and steady wins the race.

You can use it like this:

rs-fortune fortunes.txt
# May output "Fortune favors the bold."

### You can also read the fortune file path from an environment variable
FORTUNE_FILE=fortunes.txt rs-fortune 

### And it can read fortunes from pipeline
cat fortunes.txt | rs-fortune  

# Print help information
rs-fortune --help  

If <fortune file> or FORTUNE_FILE environment variable is not specified, it will print a default fortune.

This is a simple and practical command-line tool that can be used to print random quotes and sayings. Feedback and suggestions for improvement are welcome!

About

Command-line tool that prints random fortune entries. rust version of fortune

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages