use the terminal api to handle command