Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from ublue-os/listnest
Browse files Browse the repository at this point in the history
feat: nested package list
  • Loading branch information
bketelsen authored Mar 21, 2023
2 parents eed857b + 0e14c44 commit f495e19
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 49 deletions.
55 changes: 6 additions & 49 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,16 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"
"github.com/ublue-os/fleek/core"
"github.com/vanilla-os/orchid/cmdr"
)

func NewListCommand() *cmdr.Command {
cmd := cmdr.NewCommandRun(
fleek.Trans("list.use"),
fleek.Trans("list.long"),
fleek.Trans("list.short"),
list,
)
return cmd
}

// initCmd represents the init command
func list(cmd *cobra.Command, args []string) {

conf, err := core.ReadConfig()
cobra.CheckErr(err)

cmdr.Info.Println(fleek.Trans("list.userBling"), strings.ToUpper(conf.Bling))
switch conf.Bling {
case "high":
cmdr.Info.Println(fleek.Trans("list.highBling"))
case "default":
cmdr.Info.Println(fleek.Trans("list.defaultBling"))
case "low":
cmdr.Info.Println(fleek.Trans("list.lowBling"))

}
if conf.Bling == "high" {
for _, pkg := range core.HighPackages {
fmt.Printf("\t%s\n", pkg)
}
cmd := &cobra.Command{
Use: fleek.Trans("list.use"),
Long: fleek.Trans("list.long"),
Short: fleek.Trans("list.short"),
}
if conf.Bling == "default" || conf.Bling == "high" {

for _, pkg := range core.DefaultPackages {
fmt.Printf("\t%s\n", pkg)
}
}
for _, pkg := range core.LowPackages {
fmt.Printf("\t%s\n", pkg)
}

cmdr.Info.Println(fleek.Trans("list.userInstalled"))

for _, pkg := range conf.Packages {
fmt.Printf("\t%s\n", pkg)
}

cmdrcmd := &cmdr.Command{Command: cmd}
return cmdrcmd
}
62 changes: 62 additions & 0 deletions cmd/list_packages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"
"github.com/ublue-os/fleek/core"
"github.com/vanilla-os/orchid/cmdr"
)

func NewListPackagesCommand() *cmdr.Command {
cmd := cmdr.NewCommandRun(
fleek.Trans("listPackages.use"),
fleek.Trans("listPackages.long"),
fleek.Trans("listPackages.short"),
list,
)
return cmd
}

// initCmd represents the init command
func list(cmd *cobra.Command, args []string) {

conf, err := core.ReadConfig()
cobra.CheckErr(err)

cmdr.Info.Println(fleek.Trans("listPackages.userBling"), strings.ToUpper(conf.Bling))
switch conf.Bling {
case "high":
cmdr.Info.Println(fleek.Trans("listPackages.highBling"))
case "default":
cmdr.Info.Println(fleek.Trans("listPackages.defaultBling"))
case "low":
cmdr.Info.Println(fleek.Trans("listPackages.lowBling"))

}
if conf.Bling == "high" {
for _, pkg := range core.HighPackages {
fmt.Printf("\t%s\n", pkg)
}
}
if conf.Bling == "default" || conf.Bling == "high" {

for _, pkg := range core.DefaultPackages {
fmt.Printf("\t%s\n", pkg)
}
}
for _, pkg := range core.LowPackages {
fmt.Printf("\t%s\n", pkg)
}

cmdr.Info.Println(fleek.Trans("listPackages.userInstalled"))

for _, pkg := range conf.Packages {
fmt.Printf("\t%s\n", pkg)
}

}
4 changes: 4 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ add:

list:
use: "list"
long: "List installed packages or programs"
short: "List installed packages or programs"
listPackages:
use: "packages"
long: "List installed packages"
short: "List installed packages"
userBling: "Your Bling Level:"
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func main() {
repo.AddCommand(repoadd)

list := cmd.NewListCommand()
listPkgs := cmd.NewListPackagesCommand()
list.AddCommand(listPkgs)
root.AddCommand(list)
// run the app
err := fleek.Run()
Expand Down

0 comments on commit f495e19

Please sign in to comment.