Crates.io | currency_converter_cli |
lib.rs | currency_converter_cli |
version | 1.0.0 |
source | src |
created_at | 2024-06-15 21:27:27.352515 |
updated_at | 2024-06-22 11:06:41.851367 |
description | A simple CLI tool to convert GBP to CNY using real-time exchange rates. |
homepage | https://github.com/xyf2002/currency_converter |
repository | https://github.com/xyf2002/currency_converter |
max_upload_size | |
id | 1273135 |
size | 49,704 |
A simple CLI tool to convert currencies using real-time exchange rates.
Clone the repository:
git clone https://github.com/yourusername/currency_converter.git
cd currency_converter
Create a .env
file in the project root directory and add your API key:
echo "EXCHANGE_RATE_API_KEY=your_api_key_here" > .env
Build the project:
cargo build --release
To convert an amount from one currency to another, run the following command:
./target/release/currency_converter convert --amount <AMOUNT> --from <SOURCE_CURRENCY> --to <TARGET_CURRENCY>
For example, to convert 100 GBP to CNY:
./target/release/currency_converter convert --amount 100 --from GBP --to CNY
To reverse convert an amount to the source currency, run the following command:
./target/release/currency_converter reverse-convert --amount <AMOUNT> --from <SOURCE_CURRENCY> --to <TARGET_CURRENCY>
For example, to find out how much GBP is needed to get 100 CNY:
./target/release/currency_converter reverse-convert --amount 100 --from GBP --to CNY
To list all available currencies, run:
./target/release/currency_converter list-currencies
You can also run the tool in an interactive menu mode:
./target/release/currency_converter
In the interactive menu, you will have the following options:
=============================
Currency Converter Menu:
=============================
1. Convert currency
2. Reverse convert currency
3. List available currencies
Q. Quit
=============================
Enter your choice:
Follow the prompts to perform the desired operation.
=============================
100.00 GBP is 922.05 ¥ (Rate as of 2024-06-22 12:00:00 UTC)
=============================
or
=============================
100.00 ¥ is 10.84 GBP (Rate as of 2024-06-22 12:00:00 UTC)
=============================
This tool uses the ExchangeRate-API to fetch real-time exchange rates. You need to sign up for an API key and add it to the .env
file in the project root.
This project is licensed under the MIT License - see the LICENSE file for details.