pkg

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	GREY       string = "\033[1;30m"
	RED        string = "\033[0;31m"
	GREEN      string = "\033[0;32m"
	YELLOW     string = "\033[1;33m"
	DARKYELLOW string = "\033[2;33m"
	PURPLE     string = "\033[1;35m"
	CYAN       string = "\033[1;36m"
	NOCOLOR    string = "\033[0m"
)

Defined constant color codes, for OutputLevel.

View Source
const (
	ERROR   string = "[X]"
	SUCCESS string = "[✔]"
	INFO    string = "[I]"
)

Defined constant icon/title codes.

View Source
const Version = "v0.1.5"

Version is current version of application.

Variables

View Source
var (
	// Color and Icon of logger's "CURRENT" output message.
	Icon, Color string

	// ColorableStd is main stdargs of logger. [colorable stdargs].
	ColorableStd = models.StdArgs{
		Stdout: colorable.NewColorableStdout(),
		Stderr: colorable.NewColorableStderr(),
	}
)
View Source
var (
	// Custom configuration for survey icons and colors.
	// See [https://github.com/mgutz/ansi#style-format] for details.
	SurveyIconsConfig = func(icons *survey.IconSet) {
		icons.Question.Format = "cyan"
		icons.Question.Text = "[?]"
		icons.Help.Format = "blue"
		icons.Help.Text = "Help ->"
		icons.Error.Format = "yellow"
		icons.Error.Text = "Warning ->"
	}
)

Functions

func Alert

func Alert(l Level, msg string)

Alert, logs message at given Level.

l - (Level) decides style(Level) of log message. msg - (message) is the content of log message.

func Delete

func Delete(path string) error

Delete, removes file or folder, from given path.

func FileExists

func FileExists(path string) bool

FileExists, checks if any type of file exists at given path.

func IsDir

func IsDir(path string) bool

IsDir checks if the file (at provided path) is directory or not.

func IsIgnorable

func IsIgnorable(s string, ignore []string) bool

IsIgnorable is a boolean to check if provided [s] value is in [ignore] list or not.

func IsPathUpdated

func IsPathUpdated(old, current models.Settings, t string) bool

IsPathUpdated checks notes' differences of [old] and [current] settings. Appropriate to base service-type. Provided from [t].

Note: This function moved from models/settings.go, because go doesn't allow to do import cycle.

func IsSettingsUpdated

func IsSettingsUpdated(old, current models.Settings) bool

IsSettingsUpdated compares [old] and [current] Settings models. If any field of [old] is different that [current], result eventually gonna be [true].

Note: This function moved from models/settings.go, because go doesn't allow to do import cycle.

func IsType

func IsType(typ string, isDir bool) bool

IsType is a boolean value generated by [typ] and [info] type matching.

func ListDir

func ListDir(root, currentPath, typ string, ignore []string, level int) ([]string, [][]string, error)

ListDir, reads all files from given-path directory. and returns: 1. a slice of exact names of files and folders + subfiles and subfolders. 2. nested hierarchy of first array

func NewFolder

func NewFolder(name string) error

NewFolder, creates new empty working directory at given path(name).

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes given path and returns a normalized path.

func NotyaPWD

func NotyaPWD(settings models.Settings) (*string, error)

NotyaPWD, generates path of notya's notes directory. ╭───────────────────────╮ ╭────────╮ ╭────────────╮ │ ~/user-home-directory │ + │ /notya │ = │ local path │ ╰───────────────────────╯ ╰────────╯ ╰────────────╯

func OpenViaEditor

func OpenViaEditor(filepath string, stdargs models.StdArgs, settings models.Settings) error

OpenViaEditor opens file in custom(appropriate from settings) from given path.

func OutputLevel

func OutputLevel(l Level) string

OutputLevel sets Color and Icon by given Level, and then, returns final printable Level title.

Result cases: ERROR - (powered with red color) [OK] - (powered with green color) INFO - (powered with yellow color)

func Print

func Print(data string, c color.Attribute)

Print, prints given data by combining it with given color attribute.

func PrintErrors

func PrintErrors(act string, errs []error)

PrintErrors, is general error logger for push and fetch command error results.

func PrintNodes

func PrintNodes(list []models.Node)

PrintNotes, logs given nodes list.

func PrintNote

func PrintNote(note models.Note)

ShowNote, logs given full note.

func PrintServices

func PrintServices(c string, services []string)

PrintServices logs given service names by provided color level.

func PrintSettings

func PrintSettings(settings models.Settings)

PrintSettings, logs given settings model.

func ReadBody

func ReadBody(path string) (*string, error)

ReadBody, opens file from given path, and takes its body to return.

func Spinner

func Spinner() *spinner.Spinner

Spinner generates static style notya spinner.

func WriteNote

func WriteNote(path, body string) error

WriteNote, creates new file and writes to its data. If file already exists at given path with same name, then it updates it's body.

Could be used for create and edit.

Types

type Level

type Level string

Level is a custom type of [string-level]. used to define level for OutputLevel function.

const (
	ErrorL   Level = "error"
	SuccessL Level = "success"
	InfoL    Level = "info"
)

Defined constant app Levels.

Jump to

Keyboard shortcuts

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