#!/usr/bin/env python3 """ Utility to convert an IPv4 address to an int, or an int to an IPv4 address. """ import ipaddress import click @click.command() @click.argument("ips", nargs=-1, type=int) def int2ip(ips): for ip in ips: convip = ipaddress.ip_address(ip) print(f"{ip} → {convip}") @click.command() @click.argument("ips", nargs=-1, type=str) def ip2int(ips): for ip in ips: convip = int(ipaddress.ip_address(ip)) print(f"{ip} → {convip}")