add init and exit for commanline