cli

package
v0.1.4-beta.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Init struct {
	Options struct {
		Name        string `alt:"n" desc:"Specify the project name that will be used for exporting" default:"untitled"`
		Minecraft   string `alt:"m" desc:"Specify the target Minecraft version. Use '-' to indicate version ranges, e.g. '1.20-1.21'" default:"1.21.11"`
		PackVersion string `alt:"v" desc:"Specify the project version using semantic versioning" default:"0.1.0-alpha"`
		Description string `alt:"d" desc:"Specify the project description"`
	}
	Args struct {
		WorkDir *string
	}
}
View Source
var InitProgram = libparsex.Program{
	Name:        "init",
	Description: "Initialize a new Mime project",
	Options:     &Init.Options,
	Args:        &Init.Args,
	Commands:    []*libparsex.Program{},
	EntryPoint: func(raw_args []string) error {
		if Init.Args.WorkDir != nil {
			if err := os.Chdir(*Init.Args.WorkDir); err != nil {
				return liberrors.NewIO(err, *Init.Args.WorkDir)
			}
		}

		if Main.Options.Debug {
			liblog.LogLevel = liblog.LEVEL_DEBUG
		}

		mcmeta_body, err := os.ReadFile("pack.mcmeta")
		if err != nil {
			liblog.Info(0, "Missing existing 'pack.mcmeta', so one will be created instead")
			mcmeta_body = []byte{}
		}

		mcmeta := minecraft.NewPackMcmeta(mcmeta_body)
		if value := Init.Options.Description; value != "" {
			mcmeta.File.Set("pack.description", value)
		}
		mcmeta.File.Set("meta.name", Init.Options.Name)
		if parts := strings.SplitN(Init.Options.Minecraft, "-", 2); len(parts) == 2 {
			mcmeta.File.Set("meta.minecraft.min", parts[0])
			mcmeta.File.Set("meta.minecraft.max", parts[1])
		} else {
			mcmeta.File.Set("meta.minecraft", Init.Options.Minecraft)
		}
		mcmeta.File.Set("meta.version", Init.Options.PackVersion)

		err = os.WriteFile("pack.mcmeta", mcmeta.File.Formatted(), os.ModePerm)
		if err != nil {
			work_dir, _ := os.Getwd()
			return liberrors.NewIO(err, filepath.Join(work_dir, "pack.mcmeta"))
		}

		liblog.Done(
			0,
			"Saved 'pack.mcmeta' for name=%q version=%q minecraft=%q",
			Init.Options.Name,
			Init.Options.PackVersion,
			Init.Options.Minecraft,
		)
		return nil
	},
}
View Source
var Main struct {
	Options struct {
		Output string `alt:"o" desc:"Output directory relative to the pack working dir" default:"./build"`
		Zip    bool   `alt:"z" desc:"Export data & resource packs as .zip files"`
		Debug  bool   `alt:"d" desc:"Print verbose debug information"`
		Force  bool   `alt:"f" desc:"Force build even if the project was cached"`
	}
	Args struct {
		WorkDir *string
	}
}
View Source
var UsesPluralFolderNames bool

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL