Skip to content

Commit

Permalink
Add favourite struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Umut Isik committed Feb 14, 2020
1 parent 5b28e06 commit cd33b1b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/umutphp/awesome-cli/internal/package/manager"
"github.com/umutphp/awesome-cli/internal/package/prompter"
"github.com/umutphp/awesome-cli/internal/package/favourite"

"github.com/pkg/browser"
)
Expand Down Expand Up @@ -54,8 +55,10 @@ func RandomRepo(man manager.Manager) {
}

func Walk(man manager.Manager) {
cursor := man.Root
i := 0
cursor := man.Root
i := 0
favourites := favourite.New("awesome")
firstsel := ""

for {
prompt := prompter.Create(cursor.Name, cursor)
Expand All @@ -72,13 +75,26 @@ func Walk(man manager.Manager) {
// Where we are in the three
cursor = man.GetPWD()

// First selection
if i == 0 {
firstsel = selected
favourites.Add(favourite.New(selected))
}

// Second selection
if i == 1 {
f := favourites.GetChild(firstsel)
f.Add(favourite.New(selected))
}

i++
// Awesome tree has only three level depth
if i > 3 {
break
}
}

fmt.Println(favourites)
fmt.Println(cursor.GetURL())

browser.OpenURL(cursor.GetURL())
Expand Down

0 comments on commit cd33b1b

Please sign in to comment.