eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.87k stars 2.48k forks source link

Electron App: Add command line argument for opening a file #14082

Open chroberino opened 2 weeks ago

chroberino commented 2 weeks ago

Feature Description:

Similar to what VS Code supports with its --goto CLI argument (https://code.visualstudio.com/docs/editor/command-line#_core-cli-options) it would be great if the Theia Electron app would also support opening a file specified via a command line argument (with optionally allowing line number and character position within that file to be specified).

In combination with Theia's already existing app-project-path CLI argument, this would be very powerful.

In addition, VS Code offers the CLI arguments --new-window and --reuse-window (https://code.visualstudio.com/docs/editor/command-line#_core-cli-options). These will also make make sense for Theia/Electron when opening it via a command line call.

tsmaeder commented 2 weeks ago

Sounds like a duplicate of https://github.com/eclipse-theia/theia/issues/11255. Would you be interested in contributing a PR?

chroberino commented 2 weeks ago

Sounds like a duplicate of #11255.

Kind of. But it goes a bit beyond that. VS Code offers two CLI options to open files:

  1. --goto argument --> https://code.visualstudio.com/docs/editor/command-line#_core-cli-options
  2. file:line[:character] argument --> https://code.visualstudio.com/docs/editor/command-line#_opening-files-and-folders

The second option has been described by @kenneth-marut-work in https://github.com/eclipse-theia/theia/issues/11255. Especially in the context of invoking it from a terminal inside VS Code.

I have tried something like code myfile.txt as well (from a command prompt outside of VS Code), but without telling it what's the workspace it seems to open the last active workspace and if the given file is not within this workspace it does not even open the file. So I'd really prefer something similar to code path/to/my-workspace --goto path/to/desired-file-within-my-workspace:<line>:<col>

Would you be interested in contributing a PR?

Not sure if my skills and capacities will suffice. Let me think twice about it.