Documentation ¶
Overview ¶
Package app provides the root application capabilities for the goledger commandline interface.
This includes loading the ledger, tools for printing the ledger, and common-configuration across all of goledger.
Index ¶
- func Combine(strs [][]string, max int) ([]string, error)
- func Length(s string) int
- func ListLength(strs []string, max int) (l int)
- func PadString(s string, max int, justify_left bool) string
- type AnsiColour
- type App
- type BookPrinter
- func (b *BookPrinter) Ansi(c AnsiColour, i string) string
- func (b *BookPrinter) FormatMoney(symbol string, amount *big.Rat, maxlen int) string
- func (b *BookPrinter) FormatNumber(symbol string, amount *big.Rat) string
- func (b *BookPrinter) FormatSimpleMoney(symbol string, amount *big.Rat) string
- func (b *BookPrinter) FormatSymbol(symbol string) string
- func (b *BookPrinter) Printf(format string, a ...interface{}) (n int, err error)
- func (b *BookPrinter) Sprintf(format string, a ...interface{}) string
- func (b *BookPrinter) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Combine ¶
Combine multiple columns into one. Single list length. Right-justified. Space-separated.
func ListLength ¶
Types ¶
type AnsiColour ¶
type AnsiColour string
const Black AnsiColour = "\033[0;30m"
const BlackUL AnsiColour = "\033[4;30m"
const Blue AnsiColour = "\033[0;34m"
const BlueUL AnsiColour = "\033[4;34m"
const Red AnsiColour = "\033[0;31m"
const Reset AnsiColour = "\033[0m"
const UL AnsiColour = "\033[4m"
type App ¶
type App struct { Ledger string // Location of ledger file BaseCCY string // Conversion CCY for reporting Verbose bool // Verbose modw Divider string // Default (normally ":") Colour bool // Use Ansi Colour All bool // Use all accounts, rather than just accounts with a non-zero balance Lang string // Language for formatting }
Configuration for an Application
var DefaultApp App = App{ Ledger: "main.ledger", Verbose: false, Lang: "en", Divider: ":", Colour: true, All: false, }
Default configuration if none specified
func (*App) LoadCommand ¶
Load the root application cobra command
func (*App) NewBookPrinter ¶
Create a new BookPrinter for a specified io.Writer and decimal CCY (symbol) formatting.
Normally decs comes from GetCCYDecimal() from a book.
type BookPrinter ¶
type BookPrinter struct {
// contains filtered or unexported fields
}
BookPrinter provides formatting for console-based accounting reports
func (*BookPrinter) Ansi ¶
func (b *BookPrinter) Ansi(c AnsiColour, i string) string
func (*BookPrinter) FormatMoney ¶
Format the number (with colour if enabled) to a maximum length (between symbol and number) and return the string
func (*BookPrinter) FormatNumber ¶
func (b *BookPrinter) FormatNumber(symbol string, amount *big.Rat) string
Format the number correctly based on the symbol in a locale-specific way
func (*BookPrinter) FormatSimpleMoney ¶
func (b *BookPrinter) FormatSimpleMoney(symbol string, amount *big.Rat) string
Format money in a locale-specific way with the symbol
func (*BookPrinter) FormatSymbol ¶
func (b *BookPrinter) FormatSymbol(symbol string) string
Formal the symbol (CCY) for printing
func (*BookPrinter) Printf ¶
func (b *BookPrinter) Printf(format string, a ...interface{}) (n int, err error)
Normal Printf() but to specified io.Writier and formatting numbers in a locale-specific way
func (*BookPrinter) Sprintf ¶
func (b *BookPrinter) Sprintf(format string, a ...interface{}) string
Normal Sprintf() but formatting numbers in a locale-specific way