First pass at an API to let another program control main()