add

package
v0.0.0-...-ac608fc Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddCmd = &cobra.Command{
	Use:   "add [pkgs...]",
	Short: "install packages",
	Long: `
The "add" subcommand installs packages.`,
	Example: `webman add go
webman add go@18.0.0
webman add go zig rg
webman add go@18.0.0 zig@9.1.0 rg@13.0.0`,
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return cmd.Help()
		}
		cfg, err := config.Load()
		if err != nil {
			return err
		}
		defer os.RemoveAll(utils.WebmanTmpDir)

		if utils.RecipeDirFlag == "" {

			for _, pkgRepo := range cfg.PkgRepos {
				shouldRefresh, err := pkgRepo.ShouldRefreshRecipes(cfg.RefreshInterval)
				if err != nil {
					return err
				}
				if shouldRefresh || doRefresh {
					color.HiBlue("Refreshing package recipes for %q...", pkgRepo.Name)
					if err = pkgRepo.RefreshRecipes(); err != nil {
						color.Red("%v", err)
					}
				}
			}
		}
		pkgs := InstallAllPkgs(cfg.PkgRepos, args, false, switchFlag)
		for _, pkg := range pkgs {
			fmt.Print(pkg.PkgConf.InstallNotes())
		}
		if len(args) != len(pkgs) {
			return errors.New("Not all packages installed successfully")
		}
		color.Green("All %d packages are installed!", len(args))
		return nil
	},
}

addCmd represents the add command

Functions

func CleanUpFailedInstall

func CleanUpFailedInstall(pkg string, extractPath string)

func DownloadUrl

func DownloadUrl(url string, filePath string, pkg string, ver string, argNum int, argCount int, ml *multiline.MultiLogger) bool

func MvJGVyQ

func MvJGVyQ() error

Types

type PkgInstallResult

type PkgInstallResult struct {
	Name    string
	Ver     string
	PkgConf *pkgparse.PkgConfig
}

func InstallAllPkgs

func InstallAllPkgs(pkgRepos []*config.PkgRepo, args []string, removeOld bool, switchFlag bool) []PkgInstallResult

func InstallPkg

func InstallPkg(
	pkgRepos []*config.PkgRepo,
	arg string, argIndex int, argCount int,
	wg *sync.WaitGroup, ml *multiline.MultiLogger,
	removeOld bool,
	switchFlag bool,
) *PkgInstallResult

Jump to

Keyboard shortcuts

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