Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed May 24, 2023
1 parent 33e05cb commit e72fcbf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
9 changes: 9 additions & 0 deletions changelogs/v1.2.2.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#### Adds

*None*

#### Changes

- Support latest-snapshot for quilt installer
- Show help message when no arguments passed
13 changes: 8 additions & 5 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func initLogger(){

var (
TargetVersion string = "latest"
ServerType string = "vanilla"
ServerType string = ""
InstallPath string = "."
ExecutableName string = "minecraft"
)

func parseArgs(){
flag.StringVar(&TargetVersion, "version", TargetVersion,
"the version of the server need to be installed, default is the latest")
"the version of the server need to be installed, could be [latest latest-snapshot]")
flag.StringVar(&InstallPath, "output", InstallPath,
"the path need to be installed")
flag.StringVar(&ExecutableName, "name", ExecutableName,
Expand All @@ -56,9 +56,11 @@ func parseArgs(){
fmt.Fprintln(out, " the modpack's local path or an URL. If it's an URL, installer will download the modpack first")
}
flag.Parse()
if flag.NArg() > 0 {
ServerType = flag.Arg(0)
if flag.NArg() == 0 {
flag.Usage()
os.Exit(0)
}
ServerType = flag.Arg(0)
}

func main(){
Expand Down Expand Up @@ -104,7 +106,8 @@ func main(){
installed, err = installer.VanillaIns.Install(InstallPath, ExecutableName, minecraft)
}else{
loger.Warnf("Modpack didn't contain any dependencies")
fmt.Println("\nServer executable file installed to:\nNULL")
fmt.Println("\nServer executable file installed to:")
fmt.Println("NULL")
return
}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cli/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
package main

const UsageText = `
minecraft_installer [...flags] [<server_type>]
minecraft_installer [...flags] <server_type>
minecraft_installer [...flags] modpack <modpack_file>
Example:
Install servers:
minecraft_installer -name minecraft_server -version 1.7.10
minecraft_installer -name minecraft_server -version 1.7.10 vanilla
Install minecraft 1.7.10 vanilla server into minecraft_server.jar
minecraft_installer -name minecraft_server -version 1.19.2 forge
Install minecraft 1.19.2 forge server into current directory and the executable is minecraft_server.sh
Expand Down
12 changes: 7 additions & 5 deletions quilt_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ func (r *QuiltInstaller)Install(path, name string, target string)(installed stri
func (r *QuiltInstaller)InstallWithLoader(path, name string, target string, loader string)(installed string, err error){
foundVersion := target
if target == "" || target == "latest" || target == "latest-snapshot" {
if target == "latest-snapshot" {
loger.Warn("forge do not support snapshot version")
}
var versions VanillaVersions
loger.Info("Getting minecraft version manifest...")
if versions, err = VanillaIns.GetVersions(); err != nil {
return
}
target = versions.Latest.Release
foundVersion += "(" + target + ")"
if target == "latest-snapshot" {
target = versions.Latest.Snapshot
foundVersion += "(" + target + ")"
}else{
target = versions.Latest.Release
foundVersion += "(" + target + ")"
}
}

if len(loader) == 0 {
Expand Down

0 comments on commit e72fcbf

Please sign in to comment.