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

from grafcli.core import GrafCLI


def main():
    cli = GrafCLI()

    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())
