cmd

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UpdateCmd = &cobra.Command{
	Use:     "update [name]",
	Short:   "Update an external file (or all external files) in the modpack",
	Aliases: []string{"upgrade"},
	Args:    cobra.MaximumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {

		fmt.Println("Loading modpack...")

		packFile, packDir, err := shared.GetPackPaths()
		if err != nil {
			shared.Exitln(err)
		}

		pack, err := fileio.LoadAll(packFile)
		if err != nil {
			shared.Exitln(err)
		}

		var singleUpdatedName string
		if viper.GetBool("update.all") {
			fmt.Println("Checking for updates...")
			if err := core.UpdateAllMods(*pack); err != nil {
				shared.Exitln(err)
			}
		} else {
			if len(args) < 1 || len(args[0]) == 0 {
				shared.Exitln("Must specify a valid file, or use the --all flag!")
			}

			mod, ok := pack.Mods[args[0]]
			if !ok {
				shared.Exitln("Can't find this file; please ensure you have run packwiz refresh and use the name of the .pw.toml file (defaults to the project slug)")
			}

			if mod.Pin {
				shared.Exitln("Version is pinned; run the unpin command to allow updating")
			}

			if err := core.UpdateSingleMod(*pack, mod); err != nil {
				shared.Exitln(err)
			}

		}

		err = fileio.WriteAll(*pack, packDir)
		if err != nil {
			shared.Exitln(err)
		}

		if viper.GetBool("update.all") {
			fmt.Println("Files updated!")
		} else {
			fmt.Printf("\"%s\" updated!\n", singleUpdatedName)
		}
	},
}

UpdateCmd represents the update command

Functions

func Add

func Add(newCommand *cobra.Command)

Add adds a new command as a subcommand to packwiz

func Execute

func Execute()

Execute starts the root command for packwiz

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL