fix the main import code and provide the CLI main code as an importable function