#!/usr/bin/python3

import sys
from traceback import print_exc

#EXITCODES
# *: Minks requested exit. (see minks.__main__ @ #EXITCODES)
# 255: Minks raised an uncaught exception, or minks was not able to run.

try:
	from minks.log import log
	from minks.__main__ import main
except ModuleNotFoundError:
	print(f'{__file__}: Minks library not found.', file=sys.stderr)
	sys.exit(255)

try:
	log.info('Starting Minks...')
	main()
	log.warn('Minks exited with no return code; assuming success.')
except SystemExit as e:
	log.info(f'Minks requested exit. ({e.code})')
	sys.exit(e.code)
except Exception as e:
	log.error('Minks raised an uncaught exception.')
	log.error(f'{type(e).__name__}({e})')
	print_exc()
	sys.exit(255)
sys.exit(0)
