mirror of
				https://github.com/packwiz/packwiz.git
				synced 2025-10-31 10:34:32 +01:00 
			
		
		
		
	Added command to list all mods (#125)
This commit is contained in:
		
							
								
								
									
										48
									
								
								cmd/list.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								cmd/list.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| package cmd | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/packwiz/packwiz/core" | ||||
| 	"github.com/spf13/cobra" | ||||
| ) | ||||
|  | ||||
| // listCmd represents the list command | ||||
| var listCmd = &cobra.Command{ | ||||
| 	Use:   "list", | ||||
| 	Short: "List all the mods in the modpack", | ||||
| 	Args:  cobra.NoArgs, | ||||
| 	Run: func(cmd *cobra.Command, args []string) { | ||||
|  | ||||
| 		// Load pack | ||||
| 		pack, err := core.LoadPack() | ||||
| 		if err != nil { | ||||
| 			fmt.Println(err) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
|  | ||||
| 		// Load index | ||||
| 		index, err := pack.LoadIndex() | ||||
| 		if err != nil { | ||||
| 			fmt.Println(err) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
|  | ||||
| 		// Load mods | ||||
| 		mods, err := index.LoadAllMods() | ||||
| 		if err != nil { | ||||
| 			fmt.Println(err) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
|  | ||||
| 		// Print mods | ||||
| 		for _, mod := range mods { | ||||
| 			fmt.Println(mod.Name) | ||||
| 		} | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	rootCmd.AddCommand(listCmd) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user