utils

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const BHOJPUR_CLI_VERSION = "v0.0.8"

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation() bool

askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func BhojpurWebFuncMap

func BhojpurWebFuncMap() template.FuncMap

BhojpurWebFuncMap returns a FuncMap of functions used in different templates.

func BhojpurWebLastVersion

func BhojpurWebLastVersion() (version string)

func CamelCase

func CamelCase(in string) string

camelCase converts a _ delimited string to camel case e.g. very_important_person => VeryImportantPerson

func CamelString

func CamelString(s string) string

func CheckEnv

func CheckEnv(appname string) (apppath, packpath string, err error)

func CloseFile

func CloseFile(f *os.File)

CloseFile attempts to close the passed file or panics with the actual error

func EndLine

func EndLine() string

EndLine returns the a newline escape character

func FILE

func FILE() string

__FILE__ returns the file name in which the function was invoked

func FormatSourceCode

func FormatSourceCode(filename string)

formatSourceCode formats source files

func GetBhojpurWebWorkPath

func GetBhojpurWebWorkPath() string

func GetFileModTime

func GetFileModTime(path string) int64

GetFileModTime returns unix timestamp of `os.File.ModTime` for the given path.

func GetGOPATHs

func GetGOPATHs() []string

GetGOPATHs returns all paths in GOPATH variable.

func GetGoVersionSkipMinor

func GetGoVersionSkipMinor() string

func GetLastPublishedTime

func GetLastPublishedTime() string

func Go

func Go(f func() error) chan error

Go is a basic promise implementation: it wraps calls a function in a goroutine and returns a channel which will later return the function's return value.

func GoCommand

func GoCommand(command string, args ...string) error

GoCommand executes the passed command using Go tool

func IsBhojpurProject

func IsBhojpurProject(thePath string) bool

IsBhojpurProject checks whether the current path is a Bhojpur Web application or not

func IsExist

func IsExist(path string) bool

IsExist returns whether a file or directory exists.

func IsGOMODULE

func IsGOMODULE() bool

func IsInGOPATH

func IsInGOPATH(thePath string) bool

IsInGOPATH checks whether the path is inside of any GOPATH or not

func LINE

func LINE() int

__LINE__ returns the line number at which the function was invoked

func MacOSVersionSupport

func MacOSVersionSupport() bool

func MustCheck

func MustCheck(err error)

MustCheck panics when the error is not nil

func NoticeUpdateBhojpur

func NoticeUpdateBhojpur()

func Notify

func Notify(text, title string)

func PrintErrorAndExit

func PrintErrorAndExit(message, errorTemplate string)

func SearchGOPATHs

func SearchGOPATHs(app string) (bool, string, string)

SearchGOPATHs searchs the user GOPATH(s) for the specified application name. It returns a boolean, the application's GOPATH and its full path.

func SnakeString

func SnakeString(s string) string

snake string, XxYy to xx_yy

func SplitQuotedFields

func SplitQuotedFields(in string) []string

SplitQuotedFields is like strings.Fields but ignores spaces inside areas surrounded by single quotes. To specify a single quote use backslash to escape it: '\”

func Tmpl

func Tmpl(text string, data interface{})

func TmplToString

func TmplToString(tmpl string, data interface{}) string

TmplToString parses a text template and return the result as a string.

func UpdateLastPublishedTime

func UpdateLastPublishedTime()

TODO merge UpdateLastPublishedTime and NoticeUpdateBhojpur

func WriteToFile

func WriteToFile(filename, content string)

WriteToFile creates a file and writes content to it

Types

type DocValue

type DocValue string

func (*DocValue) Set

func (d *DocValue) Set(value string) error

func (*DocValue) String

func (d *DocValue) String() string

type ListOpts

type ListOpts []string

func (*ListOpts) Set

func (opts *ListOpts) Set(value string) error

func (*ListOpts) String

func (opts *ListOpts) String() string

type Releases

type Releases struct {
	PublishedAt time.Time `json:"published_at"`
	TagName     string    `json:"tag_name"`
}

func BhojpurWebReleasesInfo

func BhojpurWebReleasesInfo() (repos []Releases)

get info of Bhojpur Web releases

type Repos

type Repos struct {
	UpdatedAt time.Time `json:"updated_at"`
	PushedAt  time.Time `json:"pushed_at"`
}

func BhojpurWebReposInfo

func BhojpurWebReposInfo() (repos Repos)

get info of Bhojpur Web repos

type StrFlags

type StrFlags []string

The string flag list, implemented flag.Value interface

func (*StrFlags) Set

func (s *StrFlags) Set(value string) error

func (*StrFlags) String

func (s *StrFlags) String() string

Jump to

Keyboard shortcuts

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