Giter Site home page Giter Site logo

Comments (17)

maxandersen avatar maxandersen commented on August 11, 2024 2

code ~/code/myrepo ~/code/myrepo/src/myfile.java

Works as far as I'm aware.

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

related #41 and #7

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

idea:

ide://clone?repo=[url]&path=src/main/java/test.java

clone if necessary, open file path

ide://clone?open=https://github.com/starfixdev/starfix/blob/master/cli/installer/windows/installer/starfix.reg

and have "magic parsing" that detects this is a github backed url and do the right clooning and open.
similar can be done for bitbucket, gitlab, etc..

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

example patterns for gitlab, github etc. can be found at https://github.com/jbangdev/jbang/blob/478f0c8202ea189362fac80fde5a02f3e7bd1fb5/src/main/java/dev/jbang/util/Util.java

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

first step: clone/reuse repo and open file path

second step: handle case where branch does not match or file might not exist locally

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

I tried working with VS Code.
Vs Code provides code command to work from Terminal.

C:\Users\Fahad Israr>code --help
Visual Studio Code 1.57.1

Usage: code.exe [options][paths...]

To read output from another program, append '-' (e.g. 'echo Hello World | code.exe -')

Options
  -d --diff <file> <file>           Compare two files with each other.
  -a --add <folder>                 Add folder(s) to the last active window.
  -g --goto <file:line[:character]> Open a file at the path on the specified
                                    line and character position.
  -n --new-window                   Force to open a new window.
  -r --reuse-window                 Force to open a file or folder in an
                                    already opened window.
  -w --wait                         Wait for the files to be closed before
                                    returning.
  --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
  --user-data-dir <dir>             Specifies the directory that user data is
                                    kept in. Can be used to open multiple
                                    distinct instances of Code.
  -h --help                         Print usage.
  • Using the -g argument we can open the file on a specific line and character but the issue is its opening individually.
  • We can use --n or -r to decide to open a new window or reuse the existing one but either way the file opens up individually without the rest of the project.
  • If we intend to open the file only then this works fine otherwise will have to think of some other solution.

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

Oh wow.. that worked !!
I wasn't aware of that and was just trying things from the vscode cli help .

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024
  • Whenever we write something like this ide://clone?open=https://github.com/starfixdev/starfix/blob/master/cli/installer/windows/installer/starfix.reg starfix application will tell us it as an invalid argument.
  • To make this work we can write starfix clone https://github.com/starfixdev/starfix/blob/master/cli/installer/windows/installer/starfix.reg .
  • To achieve this we'd have to pre-process this into something like starfix clone https://git..... .Parsing in Java is easy but I ain't sure how'd I validate it with Picocli . I am currently exploring Picocli docs to see if I can find something helpful there.

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

Is this not just because the command does not have first argument defined ?

i.e. add the following:

@CommandLine.Parameters()
    URI uri;

    @Override
    public void run() {
        System.out.println(uri);
    }

and it will let you pass the URI in as first free argument.

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

We have the first argument defined right ?
Aren't clone and config the first arguments ?

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

Yes but you can other option which will work when it is not clone or config.

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024
  • This will lead us to have something like this :
@Command(name = "clone"){
// Into Clone Command
}

@Command(name = "config) {
// Into Config Command
}
@CommandLine.Parameters()
    URI uri;

    @Override
    public void run() {
        System.out.println(uri);
    }
  • With this structure picocli will always expect a parameter.
  • For instance, lets execute : starfix clone https://git/user/repo . This is what we get:
Missing required parameter: '<uri>'
Usage: <main class> [-hV] <uri> [COMMAND]
      <uri>
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.
Commands:
  clone
  config

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

I was wondering if Picocli provides something like we have for switch case in Java.

switch(var)
case "clone": 
case "config":
default:
{
// ide handler can fit in here
}

from starfix.

maxandersen avatar maxandersen commented on August 11, 2024

Mark the Uri parameter as optional. Then it is not required. See picocli Docs for the syntax.

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024
  • Yes yes,that's what I was searching for but read through somewhere in the Picocli that single valued parameters are mandatory
  • Recently learnt about setting arity , probably setting it can make it optional. I am trying with that .

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

I had made changes to the PR yesterday.
Have a look if it looks fine.

from starfix.

fahad-israr avatar fahad-israr commented on August 11, 2024

Can close this issue ?

from starfix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.