utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 16 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 CheckIfError added in v0.2.0

func CheckIfError(err error)

CheckIfError panics on os.Exit(1) if error

func CurrentYear

func CurrentYear() string

CurrentYear returns the current calendar year as a string.

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 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 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 ToLibFilename

func ToLibFilename(txt string) string

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

func ToMDFile

func ToMDFile(text string) string

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

func ToPageVariableName added in v0.2.8

func ToPageVariableName(txt string) string

ToPageVariableName returns a human readable string replacing '-' with white space and capitalizing first letters of each word.

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 ToValidName added in v0.2.8

func ToValidName(txt string) string

ToValidName returns a copy of string replacing '_' with '-' example: ToValidName("getting_started") returns 'getting-started'.

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 ListWriter added in v0.3.0

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

ListWriter is the struct wrapping the list.Writer.

func NewListWriter added in v0.3.0

func NewListWriter() ListWriter

NewListWriter creates a new ListWriter.

func (ListWriter) AppendItem added in v0.3.0

func (lw ListWriter) AppendItem(message string)

AppendItem addend an item to the ListWriter.

func (ListWriter) Indent added in v0.3.0

func (lw ListWriter) Indent()

Indent applies indent the output.

func (ListWriter) Render added in v0.3.0

func (lw ListWriter) Render() string

Render printout the ListWriter to the stadout.

func (ListWriter) Reset added in v0.3.0

func (lw ListWriter) Reset()

Reset the ListWriter.

func (ListWriter) SetBulletTriangleStyle added in v0.3.0

func (lw ListWriter) SetBulletTriangleStyle()

SetBulletTriangleStyle sets BulletTriangle as style to the ListWriter.

func (ListWriter) SetStyle added in v0.3.0

func (lw ListWriter) SetStyle(style list.Style)

SetStyle sets the list style to be applied on the ListWriter.

func (ListWriter) UnIndent added in v0.3.0

func (lw ListWriter) UnIndent()

UnIndent applies unindent to the outout.

type Logger added in v0.3.0

type Logger interface {
	SetTitle(text string)
	GetTitle() string
	SetContent(text string)
	GetContent() string
	Reset()
}

Logger interface declares the methods to set the loggers props.

type Printer added in v0.3.0

type Printer interface {
	Print()
}

Printer interface declares just the single method for printing the buffer content.

type PrinterBuffer

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

PrinterBuffer is the struct representing the buffer.

func PrettyPrinter

func PrettyPrinter(tl *TextLogger) PrinterBuffer

PrettyPrinter returns a PrinterBuffer as formatted content ready to be printout to stdout.

func (PrinterBuffer) Print

func (pb PrinterBuffer) Print()

Print prints out the buffer content to the stdout.

func (PrinterBuffer) ToString

func (pb PrinterBuffer) ToString() string

ToString returns the buffer content as string.

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.

type TextLogger added in v0.3.0

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

TextLogger is the struct used to write on the stdout as plain text.

func NewTextLogger added in v0.3.0

func NewTextLogger() *TextLogger

NewTextLogger returns a pointer to a TextLogger.

func (*TextLogger) GetContent added in v0.3.0

func (tl *TextLogger) GetContent() string

GetContent returns the TextLogger content as string.

func (*TextLogger) GetTitle added in v0.3.0

func (tl *TextLogger) GetTitle() string

GetTitle returns the TextLogger title as string.

func (*TextLogger) Reset added in v0.3.0

func (tl *TextLogger) Reset()

Reset the TextLogger.

func (*TextLogger) SetContent added in v0.3.0

func (tl *TextLogger) SetContent(content string)

SetContent sets the content for the TextLogger.

func (*TextLogger) SetTitle added in v0.3.0

func (tl *TextLogger) SetTitle(title string)

SetTitle sets the title for the TextLogger.

Jump to

Keyboard shortcuts

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