|
|
- package main
-
- import (
- "flag"
- "fmt"
-
- "PackageManager/Client/Database"
- "PackageManager/Client/Filesystem"
- "PackageManager/Color"
- "PackageManager/Helper"
- "PackageManager/Variables"
- )
-
- func main() {
- var (
- getFilesystemDiffFlag bool
- getFilesystemDiffFlagLong bool
- addFileDiffFlag bool
- addFileDiffFlagLong bool
- commitAddedFilesFlag bool
- commitAddedFilesFlagLong bool
- resetAddedFilesFlag bool
- resetAddedFilesFlagLong bool
-
- e error
- )
-
- e = Helper.CheckRoot()
- if e != nil {
- fmt.Println(Color.Fatal(e))
- return
- }
-
- e = Database.InitDB()
- if e != nil {
- panic(e)
- }
-
- // TODO: Rework usage function
-
- // Initialise flags
-
- flag.BoolVar(&getFilesystemDiffFlag, "Fd", false, "Filesystem diff")
- flag.BoolVar(&getFilesystemDiffFlagLong, "fs-diff", false, "Filesystem diff")
-
- flag.BoolVar(&addFileDiffFlag, "Af", false, "Add files")
- flag.BoolVar(&addFileDiffFlagLong, "add-files", false, "Add files")
-
- flag.BoolVar(&commitAddedFilesFlag, "Cf", false, "Add files")
- flag.BoolVar(&commitAddedFilesFlagLong, "commit", false, "Add files")
-
- flag.BoolVar(&resetAddedFilesFlag, "Rf", false, "Reset added files")
- flag.BoolVar(&resetAddedFilesFlagLong, "reset", false, "Reset added files")
-
- flag.Parse()
-
- if getFilesystemDiffFlag || getFilesystemDiffFlagLong {
- var rootPath string = Variables.RootDir
- if len(flag.Args()) > 1 {
- // TODO: Fix this msg
- fmt.Println(Color.Fatal("Option takes one optional argument"))
- flag.Usage()
- return
- }
-
- if len(flag.Args()) == 1 {
- rootPath = flag.Arg(0)
- }
-
- e = Filesystem.ShowFilesystemDiff(rootPath)
- if e != nil {
- panic(e)
- }
-
- return
- }
-
- if addFileDiffFlag || addFileDiffFlagLong {
- if len(flag.Args()) > 1 && len(flag.Args()) < 1 {
- fmt.Println(Color.Fatal("Must supply one argument"))
- flag.Usage()
- return
- }
- e = Filesystem.PickFiles(flag.Arg(0))
- if e != nil {
- panic(e)
- }
- return
- }
-
- if commitAddedFilesFlag || commitAddedFilesFlagLong {
- e = Filesystem.CommitFiles()
- if e != nil {
- panic(e)
- }
- return
- }
-
- if resetAddedFilesFlag || resetAddedFilesFlagLong {
- e = Filesystem.ResetAllPickedFiles()
- 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)
- }
|