slp/main.go

45 lines
647 B
Go
Raw Normal View History

2017-08-31 00:50:03 +00:00
package main
import (
"fmt"
"os"
"github.com/Zac-Garby/plp/args"
2017-08-31 10:55:23 +00:00
"github.com/Zac-Garby/plp/operators"
)
2017-08-31 00:50:03 +00:00
func main() {
arg := os.Args
if len(arg) <= 1 {
fmt.Println(`plp - Pluto Package Manager
+<package> installs a package
-<package> removes a package
^<package> updates a package`)
return
}
2017-08-31 00:50:03 +00:00
ops, err := args.Parse(os.Args[1:])
if err != nil {
fmt.Println(err)
return
}
2017-08-31 10:55:23 +00:00
for _, op := range ops {
var err error
switch op.Type {
case args.INSTALL:
err = operators.Install(op.Package)
case args.REMOVE:
err = operators.Remove(op.Package)
}
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
2017-08-31 00:50:03 +00:00
}