github.com/drellem2/pogo@v0.0.0-20240503070746-2c2b76da329a/cmd/lsp/main.go (about) 1 //////////////////////////////////////////////////////////////////////////////// 2 ///////////// Main file for the CLI tool /////////////////////////////////////// 3 //////////////////////////////////////////////////////////////////////////////// 4 5 package main 6 7 import ( 8 "fmt" 9 "log" 10 "sort" 11 12 "github.com/spf13/cobra" 13 14 "github.com/drellem2/pogo/internal/client" 15 ) 16 17 func main() { 18 var rootCmd = &cobra.Command{Use: "lsp"} 19 // The following behavior will be executed when the root command `rootCmd` is used: 20 rootCmd.Run = func(cobraCmd *cobra.Command, args []string) { 21 projs, err := client.GetProjects() 22 if err != nil { 23 log.Fatal(err) 24 } 25 26 // Sort projs by proj.Path 27 sort.Slice(projs, func(i, j int) bool { 28 return projs[i].Path < projs[j].Path 29 }) 30 31 for _, proj := range projs { 32 fmt.Println(proj.Path) 33 } 34 } 35 36 rootCmd.Execute() 37 }