app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(strs [][]string, max int) ([]string, error)

Combine multiple columns into one. Single list length. Right-justified. Space-separated.

func Length

func Length(s string) int

func ListLength

func ListLength(strs []string, max int) (l int)

func PadString

func PadString(s string, max int, justify_left bool) string

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) LoadBook

func (app *App) LoadBook() (*book.Book, error)

Load a book from the configured ledger file

func (*App) LoadCommand

func (app *App) LoadCommand() *cobra.Command

Load the root application cobra command

func (*App) NewBookPrinter

func (app *App) NewBookPrinter(w io.Writer, decs map[string]int) *BookPrinter

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

func (b *BookPrinter) FormatMoney(symbol string, amount *big.Rat, maxlen int) string

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

func (*BookPrinter) Write

func (b *BookPrinter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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