utility

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GithubAsset = "GITHUB_ASSET"
	GDAsset     = "GODOT_ASSET"
)

Variables

This section is empty.

Functions

func CheckOrCreateDir

func CheckOrCreateDir(path string) error

create a certain directory if it doesn't exist

func CreateNewPpmConfig

func CreateNewPpmConfig(path string) error

create a new ppm.json file

func DoesPathExist

func DoesPathExist(path string) (bool, error)

check wether an absolute path exists

func Filter added in v1.1.4

func Filter[T any](arr []T, predicate func(T, int) bool) []T

returns a new slice containing all the items on which the predicate returns true

func GetFirstMatch added in v1.1.2

func GetFirstMatch[T any](arr []T, predicate func(T, int) bool) *T

get the first predicate match of the slice

returns nil if none of the items match

func GetPathsAndConfig added in v1.1.2

func GetPathsAndConfig() (Paths, PpmConfig, error)

func GetPluginIdentifier added in v1.1.4

func GetPluginIdentifier(name string) string

func GetPluginName

func GetPluginName(name string) string

func GetVersionOrNot

func GetVersionOrNot(dependency string) (string, string)

func IndexOf

func IndexOf[T comparable](target T, data []T) int

get the index of a certain item in a string slice

func IsAssetDependency added in v1.2.0

func IsAssetDependency(str string) bool

func IsGithubRepoUrl added in v1.1.3

func IsGithubRepoUrl(str string) bool

func IsUrl added in v1.1.3

func IsUrl(str string) bool

func IsUserAndRepo added in v1.1.3

func IsUserAndRepo(str string) bool

func Map added in v1.2.0

func Map[T any, N any](arr []T, predicate func(T, int) N) []N

func PrintDone

func PrintDone()

func SliceContains added in v1.1.2

func SliceContains[T comparable](target T, data []T) bool

check whether a certain item exists in a string slice

func SliceToString added in v1.1.2

func SliceToString(slice []string, seperator string) string

func Some added in v1.2.0

func Some[T any](arr []T, predicate func(T, int) bool) bool

func UpdateGithubRepo added in v1.2.0

func UpdateGithubRepo(path string) error

update a certain repository

Types

type Dependency added in v1.2.0

type Dependency struct {
	Identifier string `json:"identifier"`
	Url        string `json:"url"`
	Type       string `json:"type"`
}

func DependencyFromString added in v1.2.0

func DependencyFromString(str string) *Dependency

type LoadingVisualization added in v1.1.2

type LoadingVisualization struct {
	Active          bool
	AnimationFrames []string
	// contains filtered or unexported fields
}

func StartLoading added in v1.1.2

func StartLoading() *LoadingVisualization

create and start a new LoadingVisualziation instance

func (*LoadingVisualization) Run added in v1.1.2

func (l *LoadingVisualization) Run(speed time.Duration)

run the loading animation

func (*LoadingVisualization) Start added in v1.1.2

func (l *LoadingVisualization) Start()

prepare and run the loading animation in a new goroutine

func (*LoadingVisualization) Stop added in v1.1.2

func (l *LoadingVisualization) Stop()

stop the loading animation

type Paths

type Paths struct {
	/*
		the root of the project.

		if the project is a game, the root is on the same level
		as the godot config files.

		if the project is a plugin, the root is somewhere under /addons
	*/
	Root string

	// the path to the addons folder
	Addons string

	// the path to the ppm.json config file
	ConfigFile string
}

access different important paths in the GD project

func CreatePaths

func CreatePaths(rootPath string) Paths

create a new paths instance from the root path

func CreatePathsFromCwd

func CreatePathsFromCwd() (Paths, error)

create a new paths instance from the current working directory

type PpmConfig

type PpmConfig struct {
	IsPlugin        bool          `json:"plugin"`
	Dependencies    []*Dependency `json:"dependencies"`
	SubDependencies []*Dependency `json:"sub-dependencies"`
	// contains filtered or unexported fields
}

representing a ppm.json configuration file

func GetPluginConfig

func GetPluginConfig(dirPath string, dependency string) (PpmConfig, error)

func ParsePpmConfig

func ParsePpmConfig(filePath string) (PpmConfig, error)

parse the ppm.json file to an object

func (*PpmConfig) AddDependency

func (ppm *PpmConfig) AddDependency(dependency *Dependency)

add an item safely to the Dependencies property

func (*PpmConfig) AddSubDependency

func (ppm *PpmConfig) AddSubDependency(dependency *Dependency)

add an item safely to the sub-dependencies property

func (PpmConfig) HasDependency

func (ppm PpmConfig) HasDependency(dependency *Dependency) bool

check wether the config file has a certain dependency

func (PpmConfig) HasSubDependency

func (ppm PpmConfig) HasSubDependency(dependency *Dependency) bool

check wether the config file has a certain sub-dependency

func (PpmConfig) PrettyPrint

func (ppm PpmConfig) PrettyPrint()

func (*PpmConfig) RemoveAllDependencies

func (ppm *PpmConfig) RemoveAllDependencies()

remove ALL (sub)dependencies

func (*PpmConfig) RemoveDependency

func (ppm *PpmConfig) RemoveDependency(dependency *Dependency)

remove an item safely from the sub-dependencies property by its name

func (*PpmConfig) RemoveSubDependency

func (ppm *PpmConfig) RemoveSubDependency(dependency *Dependency)

remove an item safely from the Dependencies property by its name

func (PpmConfig) Write added in v1.1.3

func (ppm PpmConfig) Write() error

write the current state of the configuartion to the config file

Jump to

Keyboard shortcuts

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