From 68f60a7592b9d4af8bfa6634a7b344f748ae210f Mon Sep 17 00:00:00 2001 From: connerdouglass Date: Wed, 10 Nov 2021 22:29:20 -0800 Subject: [PATCH] Cleanup of entrypoint to make it a single file --- cmd/crx/build.go | 52 ------------------------------------------------ cmd/crx/main.go | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 52 deletions(-) delete mode 100644 cmd/crx/build.go diff --git a/cmd/crx/build.go b/cmd/crx/build.go deleted file mode 100644 index 61e2455..0000000 --- a/cmd/crx/build.go +++ /dev/null @@ -1,52 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - "os/exec" - - "github.com/customrealms/cli/lib" -) - -const DEFAULT_MC_VERSION = "1.17.1" - -func crxBuild() { - - var projectDir string - var mcVersion string - var outputFile string - - flag.StringVar(&projectDir, "p", ".", "plugin project directory") - flag.StringVar(&mcVersion, "mc", DEFAULT_MC_VERSION, "Minecraft version number target") - flag.StringVar(&outputFile, "o", "", "output JAR file path") - - flag.CommandLine.Parse(os.Args[2:]) - - if len(outputFile) == 0 { - fmt.Println("Output JAR file is required: -o option") - os.Exit(1) - } - - // Build the local directory - cmd := exec.Command("npm", "run", "build") - cmd.Dir = projectDir - if err := cmd.Run(); err != nil { - panic(err) - } - - // Define the specification for the JAR template - jarTemplate := lib.JarTemplate{ - MCVersion: mcVersion, - } - - if err := lib.BundleJar( - projectDir, - &jarTemplate, - mcVersion, - outputFile, - ); err != nil { - panic(err) - } - -} diff --git a/cmd/crx/main.go b/cmd/crx/main.go index d535e53..c179362 100644 --- a/cmd/crx/main.go +++ b/cmd/crx/main.go @@ -1,11 +1,16 @@ package main import ( + "flag" "fmt" "os" + "os/exec" + + "github.com/customrealms/cli/lib" ) const VERSION = "0.1.0" +const DEFAULT_MC_VERSION = "1.17.1" func main() { @@ -27,3 +32,43 @@ func main() { } } + +func crxBuild() { + + var projectDir string + var mcVersion string + var outputFile string + + flag.StringVar(&projectDir, "p", ".", "plugin project directory") + flag.StringVar(&mcVersion, "mc", DEFAULT_MC_VERSION, "Minecraft version number target") + flag.StringVar(&outputFile, "o", "", "output JAR file path") + + flag.CommandLine.Parse(os.Args[2:]) + + if len(outputFile) == 0 { + fmt.Println("Output JAR file is required: -o option") + os.Exit(1) + } + + // Build the local directory + cmd := exec.Command("npm", "run", "build") + cmd.Dir = projectDir + if err := cmd.Run(); err != nil { + panic(err) + } + + // Define the specification for the JAR template + jarTemplate := lib.JarTemplate{ + MCVersion: mcVersion, + } + + if err := lib.BundleJar( + projectDir, + &jarTemplate, + mcVersion, + outputFile, + ); err != nil { + panic(err) + } + +}