Lion Fullscreen Desktop Switching Quirk
I'd recommend not allocating any GUI elements until after the command line input is finished. 

If you run your app from a non-fullscreen Terminal, you'll probably notice that the app launches in the Dock (even if no windows appear) before you finish entering your command line stuff. This is probably what's causing the Space-switch.