cli

package
v0.1.2-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: ISC Imports: 10 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)
			}
		}

		mcmeta_body, err := os.ReadFile("pack.mcmeta")
		if err != nil {
			LogInfo(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"))
		}

		LogDone(
			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 Output io.Writer = os.Stdout
View Source
var UsesPluralFolderNames bool

Functions

func ColorWord

func ColorWord(word, color string) string

func LogCached

func LogCached(nesting uint, format string, args ...any)

func LogDebug

func LogDebug(nesting uint, format string, args ...any)

func LogDone

func LogDone(nesting uint, format string, args ...any)

func LogError

func LogError(nesting uint, format string, args ...any)

func LogInfo

func LogInfo(nesting uint, format string, args ...any)

func LogWarn

func LogWarn(nesting uint, format string, args ...any)

Types

This section is empty.

Jump to

Keyboard shortcuts

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