utils

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package utils ...

Package utils ...

Package utils ...

Package utils ...

Package utils ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentYear

func CurrentYear() string

CurrentYear returns the current calendar year as a string.

func ExitIfError added in v0.5.0

func ExitIfError(err error)

ExitIfError panics on os.Exit(1) if error.

func GetInstalledNPMClientList added in v0.3.0

func GetInstalledNPMClientList() []npmc.NPMClient

GetInstalledNPMClientList returns the list of installed npmClient as slice of NPMClient.

func GetNPMClientInfo added in v0.3.0

func GetNPMClientInfo(name string) (bool, string)

GetNPMClientInfo returns true and npm client version as string.

func GetNPMClientNames added in v0.3.0

func GetNPMClientNames(items []npmc.NPMClient) []string

GetNPMClientNames returns the list of installed npmClient as slice of strings.

func GetSelectedNPMClient added in v0.3.0

func GetSelectedNPMClient(in []npmc.NPMClient, name string) npmc.NPMClient

GetSelectedNPMClient returns the selected NPMClient struct out of the available ones.

func GitClone

func GitClone(sveltinTemplate *config.AppTemplate, inpath string) error

GitClone clones the git repo to the specified path.

func IsError added in v0.5.0

func IsError(err error, showMessage bool) bool

IsError returns true if error is not nil. If showMessage is true it prints out a warning with the error message.

func PlusOne

func PlusOne(x int) int

PlusOne adds one to the integer parameter.

func RetrievePackageManagerFromPkgJson added in v0.3.0

func RetrievePackageManagerFromPkgJson(appFS afero.Fs, pathToPkgJson string) (npmc.NPMClient, error)

RetrievePackageManagerFromPkgJson returns NPMClient struct parsing the package.json file.

func RetrieveProjectName added in v0.5.0

func RetrieveProjectName(appFS afero.Fs, pathToPkgJson string) (string, error)

RetrieveProjectName returns the project name as string parsing the package.json file.

func Sum

func Sum(x int, y int) int

Sum adds two integer values.

func ToBasePath added in v0.4.0

func ToBasePath(fullpath string, replace string) string

ToBasePath returns a copy of string replacing all occurrences for a string with trailing slash.

func ToLibFile added in v0.5.4

func ToLibFile(txt string) string

ToLibFile returns a string a valid lib filename example: ToLibFilename("category") returns 'getCategory.js'.

func ToMDFile

func ToMDFile(txt string) string

ToMDFile returns a string with .md suffix example: ToMDFile("welcome") returns 'welcome.md'.

func ToSlug added in v0.5.4

func ToSlug(txt string) string

ToSlug returns a copy of string with lowercase replacing "_" and whitespaces with "-" example: ToSlug("New Resource") returns new-resource.

func ToTitle

func ToTitle(txt string) string

ToTitle replace all '-' char with a white space and returns a copy of string s with all letters of string whose begin words mapped to their title case.

func ToURL

func ToURL(txt string) string

ToURL returns a trimmed string with '/' as prefix.

func ToVariableName added in v0.5.4

func ToVariableName(txt string) string

ToVariableName returns a copy of string to be used as variable name.

func Today

func Today() string

Today returns the current date as formatted string "DD-ShortMonth-YYYY".

func Trimmed

func Trimmed(txt string) string

Trimmed strips away '"' from a string.

Types

type ProgressBar added in v0.4.0

type ProgressBar struct {
	// contains filtered or unexported fields
}

ProgressBar is the struct representing a progressbar instance.

func NewProgressBar added in v0.4.0

func NewProgressBar(total int) *ProgressBar

NewProgressBar returns a pointer to a ProgressBar struct.

func (*ProgressBar) Increment added in v0.4.0

func (pb *ProgressBar) Increment()

Increment increments progress by amount of n.

func (*ProgressBar) Wait added in v0.4.0

func (pb *ProgressBar) Wait()

Wait blocks until bar is completed or aborted.

Jump to

Keyboard shortcuts

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