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, andRich
โ 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
pippackage manager
Steps
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1fa12e33135568c25d41c21bb87aa343e89eb7c1c230b415dd9d47fb8448d78
|
|
| MD5 |
acc836813b98d80f1701c6cde87cde2a
|
|
| BLAKE2b-256 |
49aeacd294c3ec79f6af3980ae3416837deaf9a563aef43ba77878d4b41cf0ee
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4e87f89ac283526bf13da32343fa73f6f980535bca1eb59bd1e1489f50bd55d
|
|
| MD5 |
05f240b28026ddfad85d4ac6288adcd2
|
|
| BLAKE2b-256 |
a97b3b9d4fc084963a62835f9361af991b5883087436723c044b20f5a8b08184
|