diff --git a/README.md b/README.md index 5455d82..c7f0d3f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# gorinth +# mrpack-install -[![Go Reference](https://pkg.go.dev/badge/github.com/nothub/gorinth.svg)](https://pkg.go.dev/github.com/nothub/gorinth) +[![Go Reference](https://pkg.go.dev/badge/github.com/nothub/mrpack-install.svg)](https://pkg.go.dev/github.com/nothub/mrpack-install) A cli application for installing Minecraft servers and [Modrinth](https://modrinth.com/) [modpacks](https://docs.modrinth.com/docs/modpacks/format_definition/). diff --git a/cmd/install.go b/cmd/install.go deleted file mode 100644 index f1f373d..0000000 --- a/cmd/install.go +++ /dev/null @@ -1,45 +0,0 @@ -package cmd - -import ( - "github.com/nothub/gorinth/http" - "github.com/spf13/cobra" - "log" - "net/url" - "os" -) - -func init() { - rootCmd.AddCommand(installCmd) -} - -var installCmd = &cobra.Command{ - Use: "install", - Short: "Install a Modrinth Modpack", - Long: `TODO`, - - Run: func(cmd *cobra.Command, args []string) { - if len(args) < 1 { - // TODO: cobra arg checks - log.Fatalln("argghh") - } - - if _, err := os.Stat(args[0]); err == nil { - // arg is existing file path - - } else if _, err := url.Parse(args[0]); err != nil { - // arg is valid url - - file, err := http.Instance.DownloadFile(args[0], ".") - if err != nil { - log.Fatalln(err) - } - log.Println("Stored mrpack to:", file) - - } else { - // arg is project id? - // TODO - } - - // TODO - }, -} diff --git a/cmd/ping.go b/cmd/ping.go index b91fddc..c8e3942 100644 --- a/cmd/ping.go +++ b/cmd/ping.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - modrinth "github.com/nothub/gorinth/modrinth/api" + modrinth "github.com/nothub/mrpack-install/modrinth/api" "github.com/spf13/cobra" ) diff --git a/cmd/root.go b/cmd/root.go index 3c70072..adee7bd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,9 @@ package cmd import ( + "github.com/nothub/mrpack-install/http" + "log" + "net/url" "os" "github.com/spf13/cobra" @@ -13,9 +16,35 @@ func init() { } var rootCmd = &cobra.Command{ - Use: "gorinth", + Use: "mrpack-install", Short: "Modrinth Modpack server deployment", Long: `A cli application for installing Minecraft servers and Modrinth modpacks.`, + + Run: func(cmd *cobra.Command, args []string) { + if len(args) < 1 { + // TODO: cobra arg checks + log.Fatalln("argghh") + } + + if _, err := os.Stat(args[0]); err == nil { + // arg is existing file path + + } else if _, err := url.Parse(args[0]); err != nil { + // arg is valid url + + file, err := http.Instance.DownloadFile(args[0], ".") + if err != nil { + log.Fatalln(err) + } + log.Println("Stored mrpack to:", file) + + } else { + // arg is project id? + // TODO + } + + // TODO + }, } func Execute() { diff --git a/cmd/server.go b/cmd/server.go index 11afd6f..869cb9f 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -2,9 +2,9 @@ package cmd import ( "fmt" - "github.com/nothub/gorinth/http" - "github.com/nothub/gorinth/mojang" - "github.com/nothub/gorinth/server" + "github.com/nothub/mrpack-install/http" + "github.com/nothub/mrpack-install/mojang" + "github.com/nothub/mrpack-install/server" "github.com/spf13/cobra" "log" ) diff --git a/go.mod b/go.mod index 6962f43..532d110 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nothub/gorinth +module github.com/nothub/mrpack-install go 1.19 diff --git a/http/client.go b/http/client.go index b0b74e9..e4b0fe9 100644 --- a/http/client.go +++ b/http/client.go @@ -26,7 +26,7 @@ var Instance *Client = nil func init() { Instance = &Client{ - UserAgent: "gorinth", + UserAgent: "mrpack-install", HTTPClient: &http.Client{}, } info, ok := debug.ReadBuildInfo() diff --git a/main.go b/main.go index 2fdb559..b9fc97b 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/nothub/gorinth/cmd" + "github.com/nothub/mrpack-install/cmd" ) func main() { diff --git a/modrinth/api/client.go b/modrinth/api/client.go index cfda8fe..436c0b6 100644 --- a/modrinth/api/client.go +++ b/modrinth/api/client.go @@ -1,7 +1,7 @@ package api import ( - "github.com/nothub/gorinth/http" + "github.com/nothub/mrpack-install/http" "log" "net/url" ) diff --git a/modrinth/mrpack/index.go b/modrinth/mrpack/index.go index f9ea35e..c94467a 100644 --- a/modrinth/mrpack/index.go +++ b/modrinth/mrpack/index.go @@ -8,7 +8,7 @@ import ( "io" ) -import modrinth "github.com/nothub/gorinth/modrinth/api" +import modrinth "github.com/nothub/mrpack-install/modrinth/api" type Index struct { FormatVersion int `json:"formatVersion"` diff --git a/modrinth/mrpack/mrpack_test.go b/modrinth/mrpack/mrpack_test.go index 6f3cf93..4ef46d3 100644 --- a/modrinth/mrpack/mrpack_test.go +++ b/modrinth/mrpack/mrpack_test.go @@ -1,7 +1,7 @@ package mrpack import ( - "github.com/nothub/gorinth/http" + "github.com/nothub/mrpack-install/http" "log" "os" "testing" diff --git a/mojang/api.go b/mojang/api.go index a8f3dfe..596e161 100644 --- a/mojang/api.go +++ b/mojang/api.go @@ -1,7 +1,7 @@ package mojang import ( - "github.com/nothub/gorinth/http" + "github.com/nothub/mrpack-install/http" ) const manifestUrl = "https://launchermeta.mojang.com/mc/game/version_manifest.json" diff --git a/server/fabric.go b/server/fabric.go index 48979a0..0adbdd2 100644 --- a/server/fabric.go +++ b/server/fabric.go @@ -2,7 +2,7 @@ package server import ( "errors" - "github.com/nothub/gorinth/http" + "github.com/nothub/mrpack-install/http" "net/url" ) diff --git a/server/paper.go b/server/paper.go index a000e75..83cf8b8 100644 --- a/server/paper.go +++ b/server/paper.go @@ -2,7 +2,7 @@ package server import ( "errors" - "github.com/nothub/gorinth/http" + "github.com/nothub/mrpack-install/http" "strconv" )