PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
532 B

  1. package Package
  2. import (
  3. "errors"
  4. "fmt"
  5. "os"
  6. "PackageManager/Archive"
  7. "PackageManager/Variables"
  8. )
  9. func InstallPackage(pkgs []string) error {
  10. var (
  11. pkg string
  12. e error
  13. )
  14. for _, pkg = range pkgs {
  15. _, e = os.Stat(pkg)
  16. if os.IsNotExist(e) {
  17. return errors.New(fmt.Sprintf("Invalid package %s", pkg))
  18. }
  19. }
  20. for _, pkg = range pkgs {
  21. fmt.Printf(
  22. "Installing %s...\n",
  23. pkg,
  24. )
  25. e = Archive.UntarGzip(pkg, Variables.DestDir)
  26. fmt.Printf(
  27. "%s successfully installed\n",
  28. pkg,
  29. )
  30. }
  31. return nil
  32. }