Console and GUI in one project
With App.ArgumentsMBS the MBS Xojo Plugins provide a convenient way to get the command line parameters. Your application can query them at startup in app.Open event and check whether there are commands which need to run as command line tool. You may get arguments like file paths to open via OpenDocument event, so you may decide about the console or desktop mode with other parameters.
If you detect no special commands, you just continue with your normal application flow. Otherwise, you branch into code to do the console portions of the application. When this returns, you can do a flush on StdoutMBS and then use ExitMBS(0) to quit the application and return error code zero. Or return any other exit code, so if the application is called in a batch environment in a shell script, you can detect whether there was an error.
In your method doing the console portion, use StdInMBS class to read input and StdOutMBS class to write output. For Windows there is a special call to StdoutMBS.AttachConsole method needed to connect StdOutMBS to the current command window.
Like to try this? Just check "Console and GUI in one project" example project coming with the MBS Xojo Util Plugin.