Hello Solus Community!

I have been doing package updates for a little while now and started learning to program in Go (Golang) about two months ago. Now I have a little tool to share with you that I hope might come in handy...

I was getting tired of writing the whole url every time I went to download a repo and that led me to write a small program that you just run and put in the repo name as a command line argument and it then downloads it for you. I call it solfetch and I will be using it going forward. It might not be the best or well written program in the world but it gets the job done. I just thought I should share it here if anyone else would be interested πŸ™‚

Below is the code:

package main

import (
	"flag"
	"log"
	"os/exec"
)

func main() {
	flag.Parse()
	var repo string = flag.Arg(0)
	
	if repo == "" {
		log.Fatalln("Usage: solfetch [repository name]")
	}

	path := "git clone https://dev.getsol.us/source/" + repo + ".git"

	cmd := exec.Command("/bin/bash", "-c", path)
	if err := cmd.Run(); err != nil {
		log.Fatal(err, "\nSpecified repository doesn't exist or your internet connection is down")
	}
}

Here is a link to download compiled binary if you don't want to compile it yourself:
https://github.com/Jacalz/go-projects/blob/master/projects/solus-packaging/solfetch?raw=true

Example of downloading brave:

./solfetch brave

    Jacalz
    Nice one in case if you want to use any directory just add this bit of code in .bashrc and
    call solfetch <packageName>

    dPMethod(){
    	packagename=$1
    	if [[ $# -lt 1 ]] ; then
    		echo "==================================================="
    	    echo "please provide the packagename"
    	    echo "example: solfetch packagename"
    	    echo "==================================================="
    	else
    		git clone https://dev.getsol.us/source/${packagename}.git	
    	fi	
    	
    }
    alias solfetch=dPMethod $1

      Girtablulu Yes I am well aware of that but I don’t like the if else syntax in bash and it was a good thing to try to do in the way to learning Go. Still gets the job done and I like it πŸ™‚

        Jacalz if you wanna have something helpfully I recommend on something which clones and updates the package in the same time πŸ™‚ is my most used bash script

          Girtablulu Sounds like a great idea! I really should get better at bash scripts since it is a bit like using a sledgehammer when you only need a hammer if you use Go for stuff like this...

            Jacalz yea was my initial thought, a slide overkill for something "simple" but still good practice

            Jacalz go ahead and expand it. It will be a good experience too there are Go pros here they may help you.
            here is the one i know in other threads buddyspencer he developed uas

              viyoriya Good to know and thanks, but I think it is slightly off topic from this post though πŸ˜‰

                Jacalz Can you explain please what is the difference of
                solfetch brave and make brave.clone?
                With my little tests your tool work in every folder, and make. app.clone work only in ~/repository folder that i made for solbuild.

                  algent Had no idea that I could do something like make brave.clone πŸ˜‚

                  I also do this in bash, simple & no dependency.
                  Personally I check if the directory already exists; if it doesn't, I clone the repo, if it does, I jump in it and do a make pull to make sure it's up-to-date.

                  Girtablulu

                  function gc {
                  	git clone https://dev.getsol.us/source/${1}.git
                  	cd ${1}
                  	ls -hl --group-directories-first
                  }

                  Did this a while back. πŸ˜€