Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for opening file at a certain line+column via CLI #54

Closed
andy0x10 opened this issue Feb 20, 2023 · 11 comments
Closed

Add support for opening file at a certain line+column via CLI #54

andy0x10 opened this issue Feb 20, 2023 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@andy0x10
Copy link

In Unity you can select any script editor to open the C# scripts...This is very useful for example for jumping to the line in the file that has a compile error or exception etc.

According to the docs:
image

These CLI parameters can be specified to jump to the correct file+line+column location. Usually the format for this is "file:line:column" where :line and :column are optional.

Is this something that could be supported in ecode (or perhaps already is)?

Also I couldn't find any CLI params in the docs or when typeing "ecode.exe -?" so perhaps some basic CLI improvement could be made here too..at least listing a basic help params.

@andy0x10
Copy link
Author

It would be great if there was also another CLI param that would ensure that this doesn't cause a new ecode process to start, but instead uses the existing one.

@SpartanJ SpartanJ self-assigned this Feb 20, 2023
@SpartanJ SpartanJ added the enhancement New feature or request label Feb 20, 2023
@SpartanJ
Copy link
Owner

This would be very useful, I'll implement it right away.
What's the default format in Unity for this call? I could use that format.

Regarding the CLI options, you can invoke the help with the standard UNIX way: ecode -h or ecode --help, -? won't work universally since ? is considered a wildcard.

Current options are:

ecode --help                                                                                                                                                                                                                                                                                                                                                                                                              [file] {OPTIONS}

    ecode

  OPTIONS:

      -h, --help                        Display this help menu
      file                              The file or folder path
      -f[file], --file=[file],
      --folder=[file]                   The file or folder path
      -d[pixel-density],
      --pixel-density=[pixel-density]   Set default application pixel density
      -c[prefers-color-scheme],
      --prefers-color-scheme=[prefers-color-scheme]
                                        Set the preferred color scheme ("light"
                                        or "dark")
      --css=[css]                       Sets the path for a custom stylesheet to
                                        load at the start of the application
      -t, --terminal                    Open a new terminal
      -l[log-level],
      --log-level=[log-level]           The level of details that the
                                        application will emmit logs.
      --fb, --framebuffer               Use frame buffer (more memory usage,
                                        less CPU usage)
      --benchmark-mode                  Render as much as possible to measure
                                        the rendering performance.
      -v, --verbose                     Print all logs to the standard output.
      -V, --version                     Prints version information
      -j[jobs], --jobs=[jobs]           Sets the number of background jobs that
                                        the application will spawn at the start
                                        of the application
      --health                          Checks for potential errors in editor
                                        setup.
      --health-lang=[health-lang]       Checks for potential errors in editor
                                        setup for a specific language.
      --health-format=[health-format]   Sets the health format report (accepted
                                        values: terminal, markdown, ascii,
                                        asciidoc)
      "--" can be used to terminate flag options and force all following
      arguments to be treated as positional options

(the health ones aren't available yet, that's for the next release =))

Regarding the single instance, I plan to implement it, but there's no standard way of doing it for a multi-platform application, and I was lazy to implement it, if possible, open a new issue for that request. Thanks

@andy0x10
Copy link
Author

Great!

I tried --help and -h in windows but they don't show anything in CLI...

image

Perhaps a seperate issue?

In Unity by default if you set an external script editor it shows this:
image
But of course it lets you add your own command-line...so I would want to change it to "$(File):$(Line):$(Column) --please-use-existing-instance-thanks"

@andy0x10
Copy link
Author

Interestingly it looks like Unity has support for adding support for external code editors:
https://docs.unity3d.com/ScriptReference/Unity.CodeEditor.IExternalCodeEditor.html

So I can make a simple plugin for this soon.

@andy0x10
Copy link
Author

Related to this - it would also be nice to be able to pass in both "--folder" and "--file". This would result in the folder being opened and the file being opened and scrolled to the specified line number.

@SpartanJ
Copy link
Owner

I was thinking the same! I'll add it.

I already verified that the help is not being printed on Windows but the command parameters work, I'll see what's happening.

@SpartanJ
Copy link
Owner

Created this issue to keep track of the other feature request.

@SpartanJ
Copy link
Owner

I'll publish a new build probably tomorrow.

New options look like:

ecode --help                                                                                                                                                                                                                  03:42:56
  [file_or_folder] {OPTIONS}

    ecode

  OPTIONS:

      -h, -?, --help                    Display this help menu
      file_or_folder                    The file or folder path to open
      -f[file], --file=[file]           The file path to open. A file path can
                                        also contain the line number and column
                                        to position the cursor when the file is
                                        opened. The format is:
                                        $FILEPATH:$LINE_NUMBER:$COLUMN. Both
                                        line number and column are optional
                                        (line number can be provided without
                                        column too).
      --folder=[folder]                 The folder path to open
      -d[pixel-density],
      --pixel-density=[pixel-density]   Set default application pixel density
      -c[prefers-color-scheme],
      --prefers-color-scheme=[prefers-color-scheme]
                                        Set the preferred color scheme ("light"
                                        or "dark")
      --css=[css]                       Sets the path for a custom stylesheet to
                                        load at the start of the application
      -t, --terminal                    Open a new terminal
      -l[log-level],
      --log-level=[log-level]           The level of details that the
                                        application will emmit logs.
      --fb, --framebuffer               Use frame buffer (more memory usage,
                                        less CPU usage)
      --benchmark-mode                  Render as much as possible to measure
                                        the rendering performance.
      -v, --verbose                     Print all logs to the standard output.
      -V, --version                     Prints version information
      -j[jobs], --jobs=[jobs]           Sets the number of background jobs that
                                        the application will spawn at the start
                                        of the application
      --health                          Checks for potential errors in editor
                                        setup.
      --health-lang=[health-lang]       Checks for potential errors in editor
                                        setup for a specific language.
      --health-format=[health-format]   Sets the health format report (accepted
                                        values: terminal, markdown, ascii,
                                        asciidoc)
      "--" can be used to terminate flag options and force all following
      arguments to be treated as positional options

@andy0x10
Copy link
Author

That's great!! Can't wait to try it.
Does it work with filePath that has quotes around it to support paths with spaces?

@SpartanJ
Copy link
Owner

It does work! :)

@andy0x10
Copy link
Author

Confirmed this is working well! Massive improvement to usability from Unity!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants