Documentation
¶
Index ¶
- Constants
- Variables
- func BackupDBFile() error
- func CheckDBFile() error
- func CheckDataDir() error
- func CleanupDBBackupFiles() error
- func ColorizeBlue(s string) string
- func ColorizeGreen(s string) string
- func ColorizeRed(s string) string
- func ColorizeYellow(s string) string
- func Completer(options []string) func(d prompt.Document) []prompt.Suggest
- func CreateLedgerTables(name string, currency string) error
- func FormatAccountsTableTitle(accountName string, currency string, balance float64) string
- func GetCashioDBPath() string
- func GetCurrencyNames() []string
- func GetDateFromUser() time.Time
- func InitializeCashio() error
- func InitializeDBConnection() error
- func PadLeft(text string, padCount int) string
- func PrecisionRoundAFloat(value float64, precision int) float64
- func ProcessExpression(input string) float64
- func RestoreTermState()
- func SaveTermState()
- func SliceContains(slice []string, item string) bool
- type Debouncer
Constants ¶
const ( ColorDefault = "\x1b[39m" ColorRed = "\x1b[91m" ColorGreen = "\x1b[32m" ColorBlue = "\x1b[94m" ColorYellow = "\x1b[33m" ColorActiveBorder = 38 ColorInactiveBorder = 246 TCellColorDefaultText = tcell.Color246 TCellColorDullText = tcell.Color242 TCellColorBorderActive = tcell.Color31 TCellColorBorderInactive = tcell.Color240 TCellColorAccountsRowActiveBg = tcell.Color237 TCellColorTransRowActiveBg = tcell.Color237 TCellColorTableAltColumns = tcell.Color235 TCellColorTableHeaderRow = tcell.Color24 TCellColorFormBg = tcell.Color236 TCellColorFormHighlight = tcell.Color24 TCellColorBlue = tcell.Color38 TCellColorGreen = tcell.Color34 TCellColorRed = tcell.Color202 )
Variables ¶
var CurrencySymbols = map[string]string{
"GBP": "£",
"INR": "₹",
"USD": "$",
}
A map of currency names to symbols
var DbConn *sql.DB
var Locales = map[string]string{
"GBP": "en-GB",
"INR": "en-IN",
"USD": "en-US",
}
A map of currencies to locales
Functions ¶
func BackupDBFile ¶ added in v0.11.0
func BackupDBFile() error
BackupDBFile creates a backup of current db file in the same dataDir location
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 CleanupDBBackupFiles ¶ added in v0.11.0
func CleanupDBBackupFiles() error
CleanupDBBackupFiles deletes DB backup files older than 5 days
func ColorizeBlue ¶
ColorizeBlue returns a given string that is formatted in blue color
func ColorizeGreen ¶
ColorizeGreen returns a given string that is formatted in green color
func ColorizeRed ¶
ColorizeRed returns a given string that is formatted in red color
func ColorizeYellow ¶
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 ¶
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 FormatAccountsTableTitle ¶ added in v0.13.0
FormatAccountsTableTitle formats the title depending on the value of account balance
func GetCashioDBPath ¶
func GetCashioDBPath() string
GetCashioDBPath reads viper config and returns the absolute path to the cashio 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 ¶
GetDateFromUser prompts the user for date input.
Date can be entered either as YYYY-MM-DD (eg: 2023-08-21) or DD (eg: 21) If DD format is used, the date will default to the day in the current month and year
func InitializeCashio ¶
func InitializeCashio() error
InitializeCashio creates ledgers table in the cashio sqlite database
func InitializeDBConnection ¶ added in v0.4.3
func InitializeDBConnection() error
func PrecisionRoundAFloat ¶ added in v0.10.0
PrecisionRoundAFloat returns the given float rounded to the precision number of places
func ProcessExpression ¶ added in v0.2.0
ProcessExpression returns the value of an arithmetic expression
Example: input of "3+4" will return 7.00
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
func SliceContains ¶ added in v0.10.0
SliceContains returns true if the slice contains given string otherwise false
Types ¶
type Debouncer ¶ added in v0.15.0
type Debouncer struct {
// contains filtered or unexported fields
}
func NewDebouncer ¶ added in v0.15.0
NewDebouncer creates a new debouncer with the specified interval
func (*Debouncer) Debounce ¶ added in v0.15.0
func (d *Debouncer) Debounce(f func())
Debounce delays the execution of function f by the debouncer's interval. If Debounce is called again before the interval has elapsed, the timer is reset.