Thanks to visit codestin.com
Credit goes to github.com

Skip to content

witoldsleczkowski/whitelist-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhitelistTool

Description

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.


Features

  • 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 startDateUtc field 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.

Usage

Basic Command

WhitelistTool --input <input_file> --output <output_file> [--start-date-utc <start_date_utc>]

Options:

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.

Example

Default Behavior:

WhitelistTool --input input.txt --output output.json

Custom Start Date:

WhitelistTool --input input.txt --output output.json --start-date-utc "2025-01-01T12:00:00+02:00"

Help Command:

To see detailed usage instructions:

WhitelistTool --help

Example 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

Input File Format

The input file should contain one phone number per line. Blank lines will be ignored.

Example Input (input.txt):

48572876000

48572908000
     
+48572876000

Output File Format

The output is a JSON array where each entry contains:

  • id: The formatted phone number.
  • phoneNumber: The same as id.
  • 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"
  }
]

Installation

Prerequisites

Ensure you have Rust installed. You can install Rust using Rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Build the Executable

  1. Clone this repository:
git clone https://github.com/yourusername/WhitelistTool.git
cd WhitelistTool
  1. Build the project in release mode:
cargo build --release
  1. The executable will be located at:
    • On Linux/macOS: target/release/WhitelistTool
    • On Windows: target\release\WhitelistTool.exe

Cross-Platform Usage

You can compile this tool for different platforms:

Compile for Linux:

cargo build --release
./target/release/WhitelistTool --input input.txt --output output.json

Compile for Windows:

cargo build --release --target x86_64-pc-windows-msvc
target\release\WhitelistTool.exe --input input.txt --output output.json

Compile for macOS:

cargo build --release --target x86_64-apple-darwin
./target/release/WhitelistTool --input input.txt --output output.json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages