def main():
    "Process CLI arguments and call appropriate functions."
    try:
        args = docopt.docopt(__doc__, version=__about__.__version__)
    except docopt.DocoptExit:
        if len(sys.argv) > 1:
            print(f"{Fore.RED}Invalid command syntax, "
                  f"check help:{Fore.RESET}\n")
        print(__doc__)
        sys.exit(1)

    print_all = False
    if not (args["--int-width"] or args["--int-height"] or args["--decimal"]):
        print_all = True

    width    = float(args["WIDTH"])
    height   = float(args["HEIGHT"])

    as_int_   = as_int(width, height)
    as_float_ = as_float(width, height)

    if args["--ndigits"]:
        as_float_ = round(as_float_, int(args["--ndigits"]))

    to_print = []

    if args["--int-width"] or print_all:
        to_print.append(f"{Fore.BLUE}{as_int_[0]!s}")

    if args["--int-height"] or print_all:
        to_print.append(f"{Fore.BLUE}{as_int_[1]!s}")

    if args["--decimal"] or print_all:
        to_print.append(f"{Fore.MAGENTA}{as_float_!s}")

    print(" ".join(to_print))
def main ( ) : try : args = docopt . docopt ( __doc__ , version = __about__ . __version__ ) except docopt . DocoptExit : if len ( sys . argv ) > 1 : print ( f"{Fore.RED}Invalid command syntax, " f"check help:{Fore.RESET}\n" ) print ( __doc__ ) sys . exit ( 1 ) print_all = False if not ( args [ "--int-width" ] or args [ "--int-height" ] or args [ "--decimal" ] ) : print_all = True width = float ( args [ "WIDTH" ] ) height = float ( args [ "HEIGHT" ] ) as_int_ = as_int ( width , height ) as_float_ = as_float ( width , height ) if args [ "--ndigits" ] : as_float_ = round ( as_float_ , int ( args [ "--ndigits" ] ) ) to_print = [ ] if args [ "--int-width" ] or print_all : to_print . append ( f"{Fore.BLUE}{as_int_[0]!s}" ) if args [ "--int-height" ] or print_all : to_print . append ( f"{Fore.BLUE}{as_int_[1]!s}" ) if args [ "--decimal" ] or print_all : to_print . append ( f"{Fore.MAGENTA}{as_float_!s}" ) print ( " " . join ( to_print ) )
Process CLI arguments and call appropriate functions.