#!/usr/bin/python3
import sys
from climb.exceptions import CLIException

from zoocli import ZooCLI


def main():
    cli = ZooCLI()

    if len(sys.argv) > 1:
        try:
            result = cli.execute(*sys.argv[1:])
            if result:
                print(result)

            return 0
        except CLIException as exc:
            print(exc)
            return 1
    else:
        cli.run()
        return 0


if __name__ == "__main__":
    sys.exit(main())
