A simple Rust CLI tool to fetch your public IP address using ifconfig.io, print it to the console (just like curl ifconfig.io), and copy it to your clipboard on macOS, Windows, or Linux.
- Fetches your public IP address via
https://ifconfig.io - Prints only the IP address (no extra text)
- Copies the IP to your clipboard:
- Uses
pbcopyon macOS - Uses
clipon Windows - Uses
xcliporxselon Linux (if available)
- Uses
- Rust (edition 2021)
- For clipboard support:
- macOS:
pbcopy(default on macOS) - Windows:
clip(default on Windows) - Linux:
xcliporxsel(install via your package manager)
- macOS:
cargo run --releaseYour IP: 203.0.113.42The IP is also copied to your clipboard if a supported clipboard tool is available.
Unit tests are included for the IP parsing logic. Run them with:
cargo testUses std::process::Command to call curl and clipboard tools.
Uses tokio for async main (though the code is synchronous).
Unit tests simulate curl output and check IP parsing.
MIT
Author Samuel Adole
