WhitelistTool is a command-line utility written in Rust that processes phone numbers from an input file and converts them into a JSON format. The tool ensures that all phone numbers are properly formatted (e.g., prefixed with +) and outputs the results to a specified JSON file. It also supports parameterizing the startDateUtc field via the CLI, with validation for ISO-8601 datetime format (%Y-%m-%dT%H:%M:%S%z).
This tool is cross-platform and works on Windows, Linux, and macOS.
- Reads phone numbers from an input file (one number per line).
- Ensures all phone numbers are formatted with a
+prefix. - Outputs the processed data as a JSON array to a specified file.
- Ignores blank lines in the input file.
- Allows parameterizing the
startDateUtcfield via CLI with validation for ISO-8601 format. - Displays the total number of successfully processed phone numbers.
- Provides detailed help and usage instructions via
--help.
WhitelistTool --input <input_file> --output <output_file> [--start-date-utc <start_date_utc>]| Option | Description |
|---|---|
--input, -i |
Input file containing phone numbers (one per line). |
--output, -o |
Output file to write the JSON data. |
--start-date-utc, -d |
Start date in UTC format (ISO-8601 with timezone, e.g., 2025-03-26T13:58:00+01:00). Default is 2025-03-26T00:00:00+00:00. |
--help, -h |
Print help information. |
--version, -V |
Print version information. |
WhitelistTool --input input.txt --output output.jsonWhitelistTool --input input.txt --output output.json --start-date-utc "2025-01-01T12:00:00+02:00"To see detailed usage instructions:
WhitelistTool --helpExample output:
CLI tool to process phone numbers into JSON format
Usage: WhitelistTool [OPTIONS]
Options:
-i, --input <INPUT> Input file containing phone numbers (one per line)
-o, --output <OUTPUT> Output file to write the JSON data
-d, --start-date-utc <START_DATE_UTC>
Start date in UTC format (ISO-8601 with timezone, e.g., 2025-03-26T13:58:00+01:00)
[default: 2025-03-26T00:00:00+00:00]
-h, --help Print help information
-V, --version Print version information
The input file should contain one phone number per line. Blank lines will be ignored.
Example Input (input.txt):
48572876000
48572908000
+48572876000
The output is a JSON array where each entry contains:
id: The formatted phone number.phoneNumber: The same asid.startDateUtc: The user-specified or default timestamp.
Example Output (output.json):
[
{
"id": "+48572876000",
"phoneNumber": "+48572876000",
"startDateUtc": "2025-01-01T12:00:00+02:00"
},
{
"id": "+48572908000",
"phoneNumber": "+48572908000",
"startDateUtc": "2025-01-01T12:00:00+02:00"
},
{
"id": "+48572876000",
"phoneNumber": "+48572876000",
"startDateUtc": "2025-01-01T12:00:00+02:00"
}
]Ensure you have Rust installed. You can install Rust using Rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- Clone this repository:
git clone https://github.com/yourusername/WhitelistTool.git
cd WhitelistTool- Build the project in release mode:
cargo build --release- The executable will be located at:
- On Linux/macOS:
target/release/WhitelistTool - On Windows:
target\release\WhitelistTool.exe
- On Linux/macOS:
You can compile this tool for different platforms:
cargo build --release
./target/release/WhitelistTool --input input.txt --output output.jsoncargo build --release --target x86_64-pc-windows-msvc
target\release\WhitelistTool.exe --input input.txt --output output.jsoncargo build --release --target x86_64-apple-darwin
./target/release/WhitelistTool --input input.txt --output output.json