import subprocess
from pprint import pprint
import typer


def ping_ip(ip_address: str, count: int) -> bool:
    """
    Ping IP_ADDRESS and return True/Flase
    """
    reply = subprocess.run(
        f"ping -c {count} -n {ip_address}",
        shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        encoding="utf-8",
    )
    if reply.returncode == 0:
        return True
    else:
        return False
    

def cli(ip: str, count: int):
    result = ping_ip(ip, count)
    if result:
        print(f"IP {ip} пингуется")
    else:
        print(f"IP {ip} не пингуется")


if __name__ == '__main__':
    typer.run(cli)