Skip to main content

A CLI library for fruit data lookup and filtering

Project description

๐Ÿ‰ Fruitpedia CLI

A beautifully crafted command-line tool to explore the world of fruits โ€” with features like fruit info lookup, color-based search, fuzzy matching, data export (JSON/CSV), and color listings.

โšก Built with Python, Click, Pandas, RapidFuzz, and Rich
โœ… UTF-8 compatible and beginner-friendly
๐Ÿ“ฆ Ready for PyPI and GitHub Actions


๐Ÿš€ Features

  • ๐Ÿ” Get fruit info โ€” Get nutrients, color, and taste of any fruit by name.
  • ๐ŸŽจ Search by color โ€” List fruits matching a given color.
  • ๐Ÿ“‹ List all colors โ€” View all supported fruit colors in the dataset.
  • ๐Ÿง  Fuzzy search โ€” Suggest closest fruit names if input is misspelled.
  • ๐Ÿ’พ Export support โ€” Export query results as JSON or CSV files.
  • โœ… UTF-8 compatible โ€” Ensures smooth console output on Windows and Linux.

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.8 or later
  • pip package manager

Steps

  1. Clone the repository:
git clone https://github.com/ningappa89/fruitpedia.git
cd fruitpedia

2. Install the package in editable mode (recommended for development):
pip install -e .

3. (Optional) Install extra dependencies if exporting or advanced features are used:
pip install pandas rapidfuzz rich

๐Ÿ“ฆ Usage Guide
The CLI is accessible via the module:
python -m fruitpedia.cli [OPTIONS]


Basic Commands
1. Get detailed info about a fruit
python -m fruitpedia.cli --info apple


output:
๐ŸŽ Fruit Information:
  Color: Red
  Taste: Sweet
  Nutrients: fiber, vitamin C

If the fruit is misspelled:
python -m fruitpedia.cli --info aplpe

Output:
โŒ Fruit 'aplpe' not found.
๐Ÿ”Ž Did you mean: apple?

2. List fruits by color
python -m fruitpedia.cli --search-color yellow

Output:
๐ŸŽจ Fruits with color 'Yellow':
  - banana
  - pineapple
  - lemon

3. List all available fruit colors
python -m fruitpedia.cli --list-colors

Output:
๐ŸŽจ Available Fruit Colors:
  - black
  - blue
  - brown
  - green
  - orange
  - pink
  - purple
  - red
  - white
  - yellow
  # ...and more

๐Ÿ’พ Export Results
Export command output to a file in either JSON or CSV format:
python -m fruitpedia.cli --search-color red --export json

This generates a file named red_output.json with all matching fruits and their details.

Supported export formats:
json
csv
โš ๏ธ Important: Export format values are strictly json or csv. Using filenames or other extensions will cause errors.


## ๐Ÿงช Manual Testing Scenarios
You can manually test each feature using VS Code Terminal or any shell:

| Scenario                         | Command                                         | Expected Behavior                                         |
|----------------------------------|--------------------------------------------------|-----------------------------------------------------------|
| Get info on a known fruit        | `--info apple`                                   | Shows detailed info on apple                             |
| Get info on an unknown fruit     | `--info unknownfruit`                            | Shows "Fruit not found" and suggests closest name         |
| Search fruits by a color         | `--search-color red`                             | Lists all fruits with red color                           |
| List all supported colors        | `--list-colors`                                  | Lists all available fruit colors                          |
| Export search results to JSON    | `--search-color yellow --export json`            | Creates `yellow_output.json` with fruits data             |
| Export search results to CSV     | `--search-color yellow --export csv`             | Creates `yellow_output.csv` with fruits data              |
| Invalid export format            | `--search-color yellow --export results.csv`     | Error about invalid export option                         |
| No options passed                | *(Run without arguments)*                        | Shows help or message prompting usage                     |



๐Ÿงฑ Project Structure
fruitpedia/
โ”‚
โ”œโ”€โ”€ fruitpedia/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py           # CLI interface using Click
โ”‚   โ”œโ”€โ”€ data.py          # Fruit data + info lookup
โ”‚   โ””โ”€โ”€ search.py        # Search & filter logic by color
โ”‚
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_cli.py      # CLI command tests
โ”‚   โ”œโ”€โ”€ test_data.py     # Data retrieval tests
โ”‚   โ””โ”€โ”€ test_search.py   # Search/filter tests
โ”‚
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ pyproject.toml


๐Ÿ™‹ Contributing
Contributions are welcome! Please follow these guidelines:

Fork the repository and create your feature branch.

Write clear, well-documented code.

Add tests for new features.

Run all tests before submitting a pull request:

pytest tests/

Format your code with black:
black fruitpedia tests

๐Ÿ“„ License
This project is licensed under the MIT License. See LICENSE for details.

โญ Support & Star
If you find this project helpful, please give it a โญ on GitHub!


Contact
For questions or feedback, please open an issue or contact me at [ningskanav89@gmail.com].

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fruitpedia-0.1.3.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fruitpedia-0.1.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file fruitpedia-0.1.3.tar.gz.

File metadata

  • Download URL: fruitpedia-0.1.3.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fruitpedia-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d1fa12e33135568c25d41c21bb87aa343e89eb7c1c230b415dd9d47fb8448d78
MD5 acc836813b98d80f1701c6cde87cde2a
BLAKE2b-256 49aeacd294c3ec79f6af3980ae3416837deaf9a563aef43ba77878d4b41cf0ee

See more details on using hashes here.

File details

Details for the file fruitpedia-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fruitpedia-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fruitpedia-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e87f89ac283526bf13da32343fa73f6f980535bca1eb59bd1e1489f50bd55d
MD5 05f240b28026ddfad85d4ac6288adcd2
BLAKE2b-256 a97b3b9d4fc084963a62835f9361af991b5883087436723c044b20f5a8b08184

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page