common

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorDefault = "\x1b[39m"
	ColorRed     = "\x1b[91m"
	ColorGreen   = "\x1b[32m"
	ColorBlue    = "\x1b[94m"
	ColorYellow  = "\x1b[33m"
)

Variables

View Source
var CurrencySymbols = map[string]string{
	"GBP": "£",
	"INR": "₹",
	"USD": "$",
}

A map of currency names to symbols

View Source
var Locales = map[string]string{
	"GBP": "en-GB",
	"INR": "en-IN",
	"USD": "en-US",
}

A map of currencies to locales

Functions

func CheckDBFile

func CheckDBFile() error

CheckDBFile checks if db_filename is present in the viper configuration file and that it exists in the filesystem, otherwise it returns an error

func CheckDataDir

func CheckDataDir() error

CheckDataDir checks if data_directory is present in the viper configuration file and that it exists in the filesystem, otherwise it returns an error

func ColorizeBlue

func ColorizeBlue(s string) string

ColorizeBlue returns a given string that is formatted in blue color

func ColorizeGreen

func ColorizeGreen(s string) string

ColorizeGreen returns a given string that is formatted in green color

func ColorizeRed

func ColorizeRed(s string) string

ColorizeRed returns a given string that is formatted in red color

func ColorizeYellow

func ColorizeYellow(s string) string

ColorizeYellow returns a given string that is formatted in yellow color

func Completer

func Completer(options []string) func(d prompt.Document) []prompt.Suggest

Completer returns matched suggestions from the list of options as the input is typed

func CreateLedgerTables

func CreateLedgerTables(name string, currency string) error

CreateLedgerTables creates required tables for a ledger

It adds an entry in the ledgers table It creates the below tables with ledger name prefixed

for example if name = uk

  • uk_accounts
  • uk_categories
  • uk_transactions
  • uk_split_transactions

func GetBankerDBPath

func GetBankerDBPath() string

GetBankerDBPath reads viper config and returns the absolute path to the banker sqlite database file as string

func GetCurrencyNames

func GetCurrencyNames() []string

GetCurrencyNames iterates through CurrencySymbols map and returns a slice of strings that contains the currency names

func GetDateFromUser added in v0.1.1

func GetDateFromUser() time.Time

func InitializeBanker

func InitializeBanker() error

InitializeBanker creates ledgers table in the banker sqlite database

func PadLeft

func PadLeft(text string, padCount int) string

PadLeft returns the text with padCount number of spaces prefixed to it

func RestoreTermState

func RestoreTermState()

RestoreTermState restores a previously saved terminal state

func SaveTermState

func SaveTermState()

SaveTermState saves the current terminal state which can then be restored if needed

Types

This section is empty.

Jump to

Keyboard shortcuts

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