Initial command system

This commit is contained in:
comp500
2019-03-17 15:04:00 +00:00
parent 63df728f42
commit a531e36713
9 changed files with 170 additions and 0 deletions

57
main.go Normal file
View File

@@ -0,0 +1,57 @@
package main
import (
"fmt"
"log"
"os"
"github.com/comp500/packwiz/core"
"github.com/urfave/cli"
// Modules of packwiz
_ "github.com/comp500/packwiz/curseforge"
)
func init() {
core.Commands = append(core.Commands, cli.Command{
Name: "delete",
Aliases: []string{"remove"},
Usage: "Delete a mod from the modpack",
Action: func(c *cli.Context) error {
cmdDelete(core.FlagsFromContext(c))
return nil
},
}, cli.Command{
Name: "delet",
Aliases: []string{"remov"},
Usage: "Delete a mod from the modpack",
Action: func(c *cli.Context) error {
cmdDelete(core.FlagsFromContext(c))
return nil
},
})
}
func main() {
app := cli.NewApp()
app.Commands = core.Commands
app.Flags = core.CLIFlags[:]
app.HideVersion = true
app.Usage = "A command line tool for creating Minecraft modpacks."
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func cmdDelete(flags core.Flags) {
mod := "demagnetize"
err := os.Remove(core.ResolveMod(mod, flags))
if err != nil {
fmt.Printf("Error removing mod: %s", err)
} else {
fmt.Printf("Mod %s removed successfully!", mod)
}
// TODO: update index
}