|
|
- package main
-
- import (
- "flag"
- "fmt"
-
- "PackageManager/Client/Database"
- "PackageManager/Client/Filesystem"
- "PackageManager/Client/Package"
- "PackageManager/Color"
- "PackageManager/Helper"
- )
-
- func main() {
- var (
- updateFilesytemFlag bool
- updateFilesytemFlagLong bool
- createPackageFlag bool
- createPackageFlagLong bool
- installLocalPackageFlag bool
- installLocalPackageFlagLong bool
-
- e error
- )
-
- e = Helper.CheckRoot()
- if e != nil {
- fmt.Println(Color.Fatal(e))
- return
- }
-
- e = Database.InitDB()
- if e != nil {
- panic(e)
- }
-
- // Initialise flags
- flag.BoolVar(&updateFilesytemFlag, "Uf", false, "Update filesystem database")
- flag.BoolVar(&updateFilesytemFlagLong, "-update-filesystem", false, "Update filesystem database")
-
- flag.BoolVar(&createPackageFlag, "Cp", false, "Create package")
- flag.BoolVar(&createPackageFlagLong, "-create-package", false, "Create Package")
-
- flag.BoolVar(&installLocalPackageFlag, "Il", false, "Install local package")
- flag.BoolVar(&installLocalPackageFlagLong, "-install-local-package", false, "Install local Package")
-
- flag.Parse()
-
- if updateFilesytemFlag || updateFilesytemFlagLong {
- e = Filesystem.UpdateFilesystemHash()
- if e != nil {
- panic(e)
- }
-
- return
- }
-
- if createPackageFlag || createPackageFlagLong {
- e = Package.CreatePackage()
- if e != nil {
- panic(e)
- }
- return
- }
-
- if installLocalPackageFlag || installLocalPackageFlagLong {
- e = Package.InstallPackage(flag.Args())
- if e != nil {
- panic(e)
- }
- return
- }
-
- flag.Usage()
- fmt.Println(Color.Fatal("Nothing to do"))
-
- //e := Archive.TarGzip("/tmp/test", "/tmp/test.tar.gz")
- //e := Archive.UntarGzip("/tmp/test.tar.gz", "/tmp/test")
- //fmt.Println(e)
- }
|