1 unstable release
Uses new Rust 2024
| 0.4.0 | Dec 2, 2025 |
|---|
#1207 in Command line utilities
31KB
386 lines
๐ฎ Tarot Card Reader
A beautiful command-line tarot card reading application written in Rust. Draw random tarot cards and receive mystical insights with colorful, formatted output.
โจ Features
- ๐ Multi-Card Draws: Draw multiple unique cards for a more detailed reading.
- ๐ด Complete Tarot Deck: Full 78-card tarot deck (22 Major Arcana + 56 Minor Arcana)
- ๐ฒ Random Card Drawing: Statistically accurate card distribution
- ๐ Card Positions: Support for upright and reversed card positions
- ๐จ Beautiful Output: Colorful, well-formatted terminal display
- ๐ JSON Export: Machine-readable output for integrations
- ๐งช Comprehensive Testing: Full test suite with 12 test cases
- ๐ Rich Meanings: Detailed interpretations for all Major Arcana cards
๐ Installation
Prerequisites
- Rust (2021 edition or later)
- Cargo (comes with Rust)
Build from Source
git clone https://gitlab.com/dump-stuff/tarot.git
cd tarot
cargo build --release
Run Directly
cargo run
๐ฏ Usage
Basic Usage
# Draw a random tarot card with beautiful formatting
tarot
# Example output:
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# โฆ TAROT CARD READING โฆ
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Card: The Fool
# Type: Major Arcana
# Position: Upright
# Meaning: Folly, mania, extravagance, intoxication, delirium, frenzy, bewrayment
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Command Line Options
| Flag | Short | Description |
|---|---|---|
--help |
-h |
Show help message and usage information |
--version |
-v |
Display version information |
--json |
-j |
Output reading in JSON format |
--number |
-n |
Set the number of cards to draw (default: 1) |
Examples
# Show help
tarot --help
# Show version
tarot --version
# Get JSON output for programmatic use
tarot --json
# Draw 3 cards
tarot --number 3
# Short flags work too
tarot -h
tarot -v
tarot -j
tarot -n 5
๐ด Card Types
Major Arcana (22 cards)
Complete set of Major Arcana cards with detailed meanings:
- The Fool, The Magician, The High Priestess, The Empress
- The Emperor, The Hierophant, The Lovers, The Chariot
- Strength, The Hermit, Wheel of Fortune, Justice
- The Hanged Man, Death, Temperance, The Devil
- The Tower, The Star, The Moon, The Sun
- Judgement, The World
Minor Arcana (56 cards)
Four suits with 14 cards each:
- Wands (Fire): Creativity, passion, energy
- Cups (Water): Emotions, relationships, spirituality
- Swords (Air): Thoughts, communication, conflict
- Pentacles (Earth): Material, career, resources
Each suit contains: Ace, 2-10, Page, Knight, Queen, King
๐จ Visual Features
- Color-coded output: Different colors for card types and positions
- Styled text: Bold headers, italic meanings, bright highlights
- Centered layout: Professional-looking card reading display
- Unicode symbols: Decorative elements (โฆ, โ) for visual appeal
๐ง Development
Running Tests
# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test
cargo test test_get_tarot_meaning_valid_card
CI/CD Pipeline
This project includes a comprehensive GitLab CI/CD pipeline (.gitlab-ci.yml) that:
- โ Automated Testing: Runs tests, clippy, and formatting checks on all MRs
- ๐๏ธ Release Builds: Creates optimized binaries on main branch merges
- ๐ฆ Automatic Releases: Generates GitLab releases with artifacts
Project Structure
tarot/
โโโ src/
โ โโโ main.rs # Main application code
โโโ cards.json # Tarot card meanings data
โโโ .gitlab-ci.yml # GitLab CI/CD pipeline configuration
โโโ Cargo.toml # Dependencies and metadata
โโโ Cargo.lock # Dependency lock file
โโโ README.md # This file
โโโ target/ # Build artifacts
Dependencies
rand = "0.8"- Random number generation for card drawingcolored = "2.0"- Terminal color and stylingserde = "1.0"- Serialization frameworkserde_json = "1.0"- JSON serialization supportonce_cell = "1.19.0"- Lazy initialization of static data
๐งช Testing
The project includes comprehensive tests covering:
- โ Card meaning retrieval and validation
- โ Random card drawing functionality
- โ Case-insensitive card lookup
- โ Error handling for invalid cards
- โ JSON serialization
- โ Text formatting and centering
- โ All Major Arcana cards validation
Run cargo test to execute the full test suite.
๐ API Reference
Core Functions
get_tarot_meaning(card_name: &str) -> Result<CardMeaning, String>
Retrieves the meaning for a specific tarot card.
draw_random_tarot_cards(count: usize) -> Vec<(String, &'static str)>
Draws a specified number of unique random cards from the full 78-card deck.
Data Structures
CardMeaning
pub struct CardMeaning {
pub upright: String,
pub reversed: String,
}
TarotReading (JSON output)
struct TarotReading {
card: String,
arcana_type: String,
position: String,
meaning: String,
}
๐ช Examples in Practice
Integration with Scripts
# Get a daily reading in JSON format
READING=$(tarot --json)
echo "Today's card: $(echo $READING | jq -r '.card')"
Sample JSON Output (for tarot -n 2 --json)
[
{
"card": "The Fool",
"arcana_type": "Major Arcana",
"position": "Upright",
"meaning": "Folly, mania, extravagance, intoxication, delirium, frenzy, bewrayment"
},
{
"card": "Three of Cups",
"arcana_type": "Minor Arcana",
"position": "Reversed",
"meaning": "Independence, alone time, hardcore partying"
}
]
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
cargo test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.
What this means:
- โ You can freely use, modify, and distribute this software
- โ You must share any modifications under the same license
- โ If you use this in a network service, you must provide the source code to users
- ๐ซ Commercial entities typically avoid AGPL due to its copyleft requirements
This license ensures the software remains free and open source while preventing proprietary commercialization.
๐ฎ Future Enhancements
- Custom card spreads (Celtic Cross, Three Card, etc.)
- Historical reading log
- Card image display in terminal
- Interactive card selection mode
- Configuration file for custom meanings
- Web API server mode
- Multiple language support
๐ Acknowledgments
- Tarot card meanings compiled from traditional interpretations
- Built with the amazing Rust ecosystem
- Colored terminal output powered by the
coloredcrate
"The cards don't lie, but they do speak in riddles." ๐ฎ
Dependencies
~1โ12MB
~89K SLoC