The Number Converter CLI is a simple Rust command-line tool that allows you to convert numbers between different bases. You can convert from decimal to hex, binary, and octal. You can also convert from hex, binary, and octal to decimal.
I was learning cairo and discovered that the output I get from calls to contract functions is in hex. I wanted to be able to read that in decimal, so I wrote this simple rust CLI.
To use the Number Converter CLI, you'll need to have Rust and Cargo installed on your system. If you haven't already, you can install Rust and Cargo by following the instructions on the Rust website.
Once Rust and Cargo are installed, follow these steps to get started:
-
Clone this repository to your local machine:
git clone https://github.com/your-username/numberconverter.git
-
Navigate to the project directory:
cd numberconverter
-
Build the project using cargo:
cargo build
The Number Converter CLI accepts four command-line arguments:
-
convert
: This subcommand is required to tell clap the command we want to run. -
base_to_convert_to
: The type of base to which you want to convert the number. Supported options arebinary
,hex
,decimal
andoctal
. -
base_to_convert_from
: The base of the number you want to convert. Supported options arebinary
,decimal
,hex
, andoctal
. -
number_to_convert
: The number you want to convert.
To run the CLI, use the following command format:
cargo run <convert> <base_to_convert_to> <base_to_convert_from> <number_to_convert>
To run the CLI in interactive mode, simply run:
cargo run
You should then type -- <convert> <base_to_convert_to> <base_to_convert_from> <number_to_convert>
For example, type: convert decimal binary 1111110111
We welcome contributions to improve the Number Converter CLI or add new features. If you'd like to contribute, please follow these steps:
-
Fork the repository to your GitHub account.
-
Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
-
Make your changes and commit them with descriptive commit messages.
-
Push your changes to your forked repository.
-
Create a pull request to the main repository.