utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TODO_PATTERN define the todo pattern for actions, which should be
	// should be in form of
	// @todo: tags-related
	// [ ] Something
	// later some form of todo.txt might come in handy.
	//
	TODO_PATTERN = "@todo "

	// Tags define tags for a specific document
	TAGS_PATTERN = "@tags "

	// name defines aliases for later references
	// "this" can't be chosen, must be unique
	NAME_PATTERN = "@name "

	// the first name will be used, if @display is not defined
	LABEL_PATTERN = "@label "

	// entity defines the different types (also defines custom icons)
	ENTITY_PATTERN = "@entity "

	// icon defines the src of custom svg images
	ICON_PATTERN = "@icon "

	// References contain information for specific objects
	// which can be link by providing the name or an alias of the object
	// and the relation it might have
	// Example:
	// @ref example
	// 		(diese resource is refereced for example (only works with entity: info))
	// @ref (this)->[:dns]->(CW)
	// 		(diese resource hat einen dns channel zum object CW)
	// @ref (fireye)->[installed]->(this)
	// 		other resources can be linked to this
	// @ref (CW)->[this]->(fireeye)
	// 		references can also define the relation itself
	REFERENCE_PATTERN = "@ref "

	VAL_DELIMITER = ","

	REFERENCE_REG_PATTERN = `\(([^)]*)\)->\[([^\]]*)\]->\(([^)]*)\)`
	THIS_REFERENCE        = "this"

	// Supported Icons
	COMPUTER_SHAPE = ""

	CLIENT   = ""
	SERVER   = ""
	DC       = ""
	ACCOUNT  = ""
	PROXY    = ""
	DATABASE = ""
	FILE     = ""
	CLOUD    = ""
	CW       = ""
)
View Source
const (
	// FKKK represents something went bad ¯\_(ツ)_/¯
	FKKK = "¯\\_(ツ)_/¯"
)

Variables

View Source
var (
	ERR_READPATH = errors.New("Path could not be read")
)

Functions

func Copy

func Copy(srcFile, dstFile string) error

func CopyDirectory

func CopyDirectory(scrDir, dest string) error
func CopySymLink(source, dest string) error

func CreateIfNotExists

func CreateIfNotExists(dir string, perm os.FileMode) error

func DirIsEmpty

func DirIsEmpty(d string) (empty bool, err error)

DirIsEmpty checks if the directory contains any files

func Exists

func Exists(filePath string) bool

func FileExist

func FileExist(p string) bool

FileExist checks if a file Exist and returns false if a file does not exist or an error occur

func FindActivities

func FindActivities(misatoPath string) []string

func FindExtension

func FindExtension(notePath, extension string) (files []string)

FindExtension returns all files with a specified extension

func FindExtensionMaxdepth

func FindExtensionMaxdepth(notePath, extension string, maxdepth int) (files []string)

FindExtensionMaxdepth todo

func FindJSON

func FindJSON(notePath string) (jsonFiles []string)

FindJSON returns all jsonFiles on the notePath

func FindMd

func FindMd(notePath string) (mdFiles []string)

FindMd returns an array of all md paths within the notes dir

func FindMilestones

func FindMilestones(misatoPath string) []string

func FindMisatoLogs

func FindMisatoLogs(misatoPath string) []string

func FindTagsInFile

func FindTagsInFile(filename string) (tags []string, err error)

FindTagsInFile returns all tags, which were found in the file

func GetAbsPath

func GetAbsPath(baseDir, fileToOpen string) (abs string, err error)

GetCleanFilePath returns the abs, clean path and verifies if the file Exists

func GetLeLExePath

func GetLeLExePath() string

func HasMDFilesChanged

func HasMDFilesChanged(since time.Time, notePath string) (changes []string, hasChanged bool)

HasMDFilesChanged validates if any mdFile changed and returns the modified files

func OpenInEditor

func OpenInEditor(executablePath, filePath string) error

OpenInEditor execute the editorPath with the filepath as an argument

func ReadLinesFromFiles

func ReadLinesFromFiles(filename string) ([]string, error)

ReadLinesFromFiles

func SearchInFile

func SearchInFile(filename string, searchword string) (bool, error)

SearchInFile searches a pattern and returns wether or not it was found

func SearchWithPreviewInFile

func SearchWithPreviewInFile(filename, searchword string) (matches []string, err error)

SearchWithPreviewInFile returns TODO , n int with previous and after line

func SliceAreEqual

func SliceAreEqual(slice1 []string, slice2 []string) bool

func SplitAndTrim

func SplitAndTrim(line, pattern string) (parts []string)

func TrimPart

func TrimPart(part, prefix string) (rest string)

func TrimParts

func TrimParts(parts []string, prefix string) []string

TrimParts returns an stripped array

func WriteTo

func WriteTo(filename string, bts []byte) error

WriteTo write the bts to filename

Types

This section is empty.

Jump to

Keyboard shortcuts

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