Home > Mobile >  How to read stdin and/or command line arguments from Electron app?
How to read stdin and/or command line arguments from Electron app?

Time:10-17

I am developing a macOS/Linux (AppImage) app.

I would like to bundle command line features so users can pipe data to app which would alter how UI is rendered.

Is that possible? If so, how?

Thanks for helping out!

CodePudding user response:

It is possible. You have the main process, in which you are creating windows and etc. You have access to process object, and hence process.argv, process.stdin and so on. You can add some logic to check command line arguments to see whether a user trying to launch your application in CLI mode or not, and then do the business logic.

So instead of just creating a window, firstly check command line arguments in process.argv.

  • Related