utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TreeBranchChar = "├── "
	TreeNodeChar   = "│   "
	TreeLastChar   = "└── "
)

Variables

View Source
var (
	AppName        = "todo-cli"
	Version        = "0.1.0"
	BuildHost      = "dev"
	BuildDate      = "2021-08-01T00:00:00Z"
	AppDescription = AppName + " v" + Version
)

Functions

func AskYesNo added in v0.1.0

func AskYesNo(defaultValue bool, prompt string, args ...any) bool

func DirectoryExists added in v0.1.0

func DirectoryExists(dirName string) error

func DurationString added in v0.1.0

func DurationString(d time.Duration) string

func FileExists added in v0.1.0

func FileExists(fileName string) error

FileExists returns true if the file exists and is not a directory TODO: Substituir todos os os.Stat por esta funçãos

func GetDefaultDataFolder added in v0.1.0

func GetDefaultDataFolder() string

func GetShellData

func GetShellData() (shellProfile string, thisPath string)

func GetUser

func GetUser() string

GetUser get username from git config, from OS or UNDEFINED

func InputText added in v0.1.0

func InputText(prompt string, defaultValue string) string

func Tern

func Tern(cond bool, a, b string) string

Types

type BackupFiles added in v0.1.0

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

func NewBackupFiles added in v0.1.0

func NewBackupFiles(backupFolder string, fileNamePrefix string, maxFiles int, validateFile func(string) error) (*BackupFiles, error)

func (*BackupFiles) GetBackupFiles added in v0.1.0

func (b *BackupFiles) GetBackupFiles() (backupFiles []string, err error)

func (*BackupFiles) GetLastBackupFile added in v0.1.0

func (b *BackupFiles) GetLastBackupFile() string

func (*BackupFiles) GetNewBackupFileName added in v0.1.0

func (b *BackupFiles) GetNewBackupFileName() string

func (*BackupFiles) Purge added in v0.1.0

func (b *BackupFiles) Purge() (err error)

type TreeNode added in v0.1.0

type TreeNode struct {
	Text string
	// contains filtered or unexported fields
}

func NewTreeNode added in v0.1.0

func NewTreeNode(id string) *TreeNode

func (*TreeNode) AddChild added in v0.1.0

func (t *TreeNode) AddChild(id string, childText string) (child *TreeNode)

func (*TreeNode) FindById added in v0.1.0

func (t *TreeNode) FindById(id string) *TreeNode

func (*TreeNode) Print added in v0.1.0

func (t *TreeNode) Print(w io.Writer)

Jump to

Keyboard shortcuts

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