Skip to content

Custom URL Protocol Handler for Windows#1

Closed
fahad-israr wants to merge 68 commits intostarfixdev:masterfrom
fahad-israr:master
Closed

Custom URL Protocol Handler for Windows#1
fahad-israr wants to merge 68 commits intostarfixdev:masterfrom
fahad-israr:master

Conversation

@fahad-israr
Copy link
Copy Markdown
Collaborator

@fahad-israr fahad-israr commented Mar 5, 2020

  • Added Custom Url Handler Methodology for Windows
  • Created a Test File
  • Checked the Output
  • All in separate Files

shell
open
command
(Default) = "C:\Program Files\Ide\ide.exe" "%1"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it actually have to be an .exe ? can it be a batch script ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we were going to deal with an Installed IDE(vscode, eclipse, etc who have an exe file) I've tried with an .exe...I'll have to check about batch script..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well before we reach the ide it would call out to the starfish which would figure out how to turn the action in ide:// to a call to the apropriate ide/tool.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so instead of an opening ide.exe we could trigger starfish.exe and handle the request in Starfish.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, correct.

@@ -0,0 +1,35 @@
# Creating Custom URL Handlers on Linux:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you avoid having mixed cases and spaces in the folder/file names ... ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed them.

@@ -0,0 +1,66 @@
# Support opening files through URL handling in Vscode
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool you found places in vscode to alter.

Any particular reason you want to modify vscode to support the protocol directly at this stage ?

One of the ideas/values behind starfish is that each IDE (at least for basic operations) should not need to support the protocol directly. Thoughts ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this was to understand the functionality of vscode.

I agree that we dont need to modify the code directly for vscode.There can be better solutions.
One of them could be through Extensions using "Extension API" of vscode.

And if we've got any better choice than an extension I can start working on that as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally I saw the command line tool of vscode :code.visualstudio.com.

With this we can easily execute vscode commands ,as stated on code.visualstudio.com "Visual Studio Code has a powerful command line interface built-in that lets you control how you launch the editor. You can open files, install extensions, change the display language, and output diagnostics through command-line options (switches)"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the mapping of URL to Application (i.e Starfish) can be done as done here: https://github.com/shengyou/vscode-handler

For mapping, we have to execute .reg Files(on Windows) or execute bash install on Linux
We can achieve this easily by automating our app to execute intended codes from command line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, vscode has url extensions too and a nice cli - the downside being it only works for vscode.

That’s why starfish would be its own independent script/executable which we register in the different OS/browsers url handler logic and then can make it work for basically any IDE.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

granted. din't realize these were publically limited. but lets use it for now.

Thanks!!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do refer to me the resources you may think might be helpful for improved learning.

quarkus.io/guides is a good start.

mind you that most material in quarkus is about using it for services (i.e. microservices) the notion of command mode for use in cli's and batch jobs is coming in 1.4 (a month from now) so to start just doing basic java should be fine.

but don't let that stop you from exploring Quarkus today! :)

That's awesome!! I'd keep exploring Quarkus and start developing with it as soon as possible!!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to do it as part of GSOC you'll make a proposal (https://google.github.io/gsocguides/student/writing-a-proposal) - for now we submit those at https://docs.google.com/forms/d/1ePMj3FRBQ_BNYo9pKSaYI9HE0uv_gTLksJWqSOqYdIw/prefill

The docs need access.I've requested access. Please check it.

Hi max,I've successfully submitted the Google form.
Please review it and give me suggestions to improve it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - I haven't received any notfication and nothing listed in the results tab - can you double check you pressed submit ? and did you send the pdf to google's gsoc system ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry...i forgot to press submit button after prefilling.
You may review my draft now.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

fahad-israr commented Mar 22, 2020

While working with Quarkus I faced a little bit of difficulty in Installing GraalVM on Ubuntu. So I've made an Installation Guide.Please Check it out,give a review to me on it(so that I can improve it) and do share with others if you think it can be helpful ...https://github.com/fahad-israr/Guide-to-Install-GraalVM-Community-Edition-On-Ubuntu

Update: Additionally, I was able to succefully Build a Native Executable with Quarkus using https://github.com/quarkusio/quarkus-quickstarts/tree/master/getting-started
And Successfully Execute the generated SNAPSHOT-runner using : ./target/getting-started-1.0-SNAPSHOT-runner

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

I am glad to mention here that My PR got accepted and merged at one of the related projects (Vscode Handler) that you suggested as a reference:shengyou/vscode-handler#5 (comment)

@maxandersen
Copy link
Copy Markdown
Member

about configuration I would start simple by having a ~/.starfish/config.yaml or similar to add user config to.

what would be great though is that we auto-detect/guess as much as possible and only in truly ambiguous cases do we need user to configure anything.

i.e. to find which IDE to launch I would simply scan PATH or well known locations for possible known ones ..i.e. if code is in the path assume its vscode

similar about launch of the IDE and how to have it pick up the right command - i.e. if /Applications/Eclipse.app exist use open -a /Applications/Eclipse.app %s on OSX etc. or when intellj with its specific port open do a curl to the IDE...

of course if you did such scan on my laptop you would basically find all in existence so here it might make sense to ask the user what he prefer and give option to "remember" the choice.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

about configuration I would start simple by having a ~/.starfish/config.yaml or similar to add user config to.

what would be great though is that we auto-detect/guess as much as possible and only in truly ambiguous cases do we need user to configure anything.

i.e. to find which IDE to launch I would simply scan PATH or well known locations for possible known ones ..i.e. if code is in the path assume its vscode

similar about launch of the IDE and how to have it pick up the right command - i.e. if /Applications/Eclipse.app exist use open -a /Applications/Eclipse.app %s on OSX etc. or when intellj with its specific port open do a curl to the IDE...

of course if you did such scan on my laptop you would basically find all in existence so here it might make sense to ask the user what he prefer and give option to "remember" the choice.

I like this Idea.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

Configuration File Added and Tested

Hi @maxandersen

I've added a configuration file that currently allows user to:

  • Specify destination directory on local files system
  • Choose which IDE to launch

I've used .properties file(see the file here )instead of YAML.

Is it fine to use .properties file instead of YAML or are there any advantages of using YAML ?

Files to see for changes:

Waiting for your thoughts :)

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

Capability to scan installed packages added

  • Scans all the installed packages
  • Currently, prints them on console

Example screenshot:

list_pkg

@maxandersen
Copy link
Copy Markdown
Member

Main reason to use yaml is its cleaner to read/write nested config, i.e.:

editors:
   code: 
      open-file-arg: {file}{#if line}:{line}{/if}{#if column}:{column}{/if}
   eclipse:
      path: open -a ~/java-latest-released/Eclipse.app
      open-file-arg: {file}

you'll want to make sure to use something like fastjackson which can help retain comments.

about package scans thats cool - not sure if it can help much; but yes - in general we'll probably want different strategies dependent on OS and setup. I would start by scanning for well known executable in the path as that is independent of if the tools/ide was installed via package or something else.

About changing preferences then yeah, I would just update the config for the user.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

@maxandersen
Thanks!!
I'll go ahead.
I'll introduce YAML instead of .properties and I'll try to work with identifying the installed IDE's and Terminal based user interaction to choose the IDE.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

Hi @maxandersen

- I've introduced a file starfish-config.yml that holds the configurations for Starfish

- I've used Simple YAML as a dependency and thus added a jar file for it: simpleyaml.jar

- The jar file must be included in classpath for compiling or running.

- To compile javac -cp '.:simpleyaml.jar' starfish.java

- To run java -cp '.:simpleyaml.jar' starfish

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

Hi @maxandersen

I have added more features

Now as the user click open In IDE in browser the terminal Launches and asks

- If he wants to use previous configuration(stored in YML File)

- If he says yes then the configuration is loaded from YAML File

- If he says no then the user is asked to enter configuration by choosing the IDE from list and enter cloning path.

- The Entered Configuration is also updated in YAML File (starfish-config.yml)


Screenshots below demonstrate both cases:

- When user wants to use the previous configuration stored in YML file:

starfish_defualt config


- When the user wants to change the configuration

starfish_user_ config

@maxandersen
Copy link
Copy Markdown
Member

i like there are way to configure it but I don't think that should happen in the browser extension when clicking on launch - at that time in all cases except the first time you should already have this configured and thus showing the terminal and asking the questions are not a good flow.

I think this configuration should be done only if no config present - after that just use the configured settings.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

fahad-israr commented May 4, 2020

yeah asking every time is not a good flow.
I'll make changes.
I was thinking of what if user wants to change the config later.
Is it fine to ask him to manually change the YAML or can there be a better solution?
One I can think is we give an option to configure options in the extension menu.
Clicking on the edit config would launch terminal and allow the user to change config.
Waiting for your thoughts :)

@maxandersen
Copy link
Copy Markdown
Member

remember starfish is just as much a command line tool - not just called via the browser extension.

thus having i.e. starfish edit-config command or similar would be just fine and/or have it available in the extension settings or similar as you suggeted.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

fahad-israr commented May 6, 2020

Yes , starfish is a command line tool and so starfish edit-config seems to be good idea.
User can then launch up this via Browser extension or even via Terminal directly.

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

- When the user opens up the starfish app first time he is asked to enter configuration

starfish-first-time-demo

- Next time onwards starfish directly uses the configuration from config file.

starfish-second-time

@fahad-israr
Copy link
Copy Markdown
Collaborator Author

command line support added for starfish and starfish config editor

- When the user enters starfish https://username/repository.git

starfish-terminal-demo

- When the user enters starfish config then configuration editor launches

starfish-config-terminal-demo

@maxandersen
Copy link
Copy Markdown
Member

closing as we merged the work here last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants