Documentation ¶
Index ¶
- Constants
- func AbsolutePathWithWD(path string) string
- func ApplyTemplate(name, tpl string, data interface{}) string
- func AskBool(name, desc string, defaultValue bool) bool
- func AskDate(name, desc string, defaultValue time.Time) string
- func AskFloat(name, desc string, defaultValue float64) float64
- func AskForConformation(question string) bool
- func AskInt(name, desc string, defaultValue int) int
- func AskIntFromList(name, desc string, searchItems SearchItems) int
- func AskIntFromListSearch(name, desc string, searchItems SearchItems) int
- func AskString(name, desc, defaultValue string) string
- func AskStringFromListSearch(name, desc string, searchItems SearchItems) string
- func AskStringFromSearch(name, desc string, searchItems SearchItems) string
- func AskStringFromSearchWithNew(name, desc string, searchItems SearchItems, ...) (value string, newElement interface{})
- func CompareFloats(a float64, b float64) bool
- func Contains(list []string, key string) bool
- func DateRangeFromYear(year int) (from, to time.Time)
- func EscapedSplit(input, sep string) []string
- func FileExist(path string) bool
- func OpenYaml(data interface{}, path, dataType string)
- func RelativeAssetPath(absolute, asset string) string
- func SaveToYaml(data interface{}, path, dataType string)
- func TerminalWidth() (int, error)
- func ValidDate(format, date string) bool
- type Checkable
- type Conditions
- type External
- type FlawLevel
- type Money
- type Report
- type SearchItem
- type SearchItems
- type Strategy
- type Table
- type TableRow
- type TransactionType
- type Validatable
- type ValidateResult
- type ValidateResults
Constants ¶
const ApplicationFolder = "/usr/share/applications/"
const DateFormat = "2006-01-02"
const GermanLayout = "02-01-2006"
Variables ¶
This section is empty.
Functions ¶
func AbsolutePathWithWD ¶
AbsolutePathWithWD returns the absolute path of a given path in relation to the current working dir. This is mainly used to normalize user inputs (like for assets).
func ApplyTemplate ¶
func AskForConformation ¶
func AskIntFromList ¶
func AskIntFromList(name, desc string, searchItems SearchItems) int
func AskIntFromListSearch ¶
func AskIntFromListSearch(name, desc string, searchItems SearchItems) int
func AskStringFromListSearch ¶
func AskStringFromListSearch(name, desc string, searchItems SearchItems) string
func AskStringFromSearch ¶
func AskStringFromSearch(name, desc string, searchItems SearchItems) string
func AskStringFromSearchWithNew ¶
func AskStringFromSearchWithNew(name, desc string, searchItems SearchItems, newFunction func(arg interface{}) interface{}, arg interface{}) (value string, newElement interface{})
func CompareFloats ¶
CompareFloats rounds both numbers to their third decimal place and compares them.
func DateRangeFromYear ¶
func EscapedSplit ¶
EscapedSplit separates a string with a given separator while ignoring separators which are escaped with a backslash (ex.: "\:" is ignored when splitting by ":" ).
func OpenYaml ¶
func OpenYaml(data interface{}, path, dataType string)
OpenYaml opens a file and tries to marshal its content to the given interface. The elementType parameter is used in error messages.
func RelativeAssetPath ¶
func SaveToYaml ¶
func SaveToYaml(data interface{}, path, dataType string)
SaveToYaml writes the element (utils) as a json file to the given path. The elementType parameter is used in error messages.
func TerminalWidth ¶
Types ¶
type Checkable ¶
type Checkable interface {
Validate() ValidateResults
}
type Conditions ¶
type External ¶
type External struct { Running bool // contains filtered or unexported fields }
func NewExternal ¶
type FlawLevel ¶
type FlawLevel int
FlawLevel states the importance of a validation error. The levels also states in which step the validation should be fixed.
const ( // UndefinedFlaw was not defined by the programmer. UndefinedFlaw FlawLevel = iota // FundamentalFlaw has to be fixed right now. FundamentalFlaw // BeforeImportFlaw should be fixed before import into Acc. BeforeImportFlaw // BeforeMergeFlaw should be fixed before using any merging functions. BeforeMergeFlaw // BeforeExportFlaw should be fixed before using export functions. BeforeExportFlaw )
type Money ¶
type Money struct {
*money.Money
}
func NewMoneyFromFloat ¶
NewMoneyFromFloat returns a new Money object from the given string. As floating point numbers are not a good idea for money this shouldn't be used. This method is only here for the Bimpf import.
func NewMonyFromDotNotation ¶
func NewMonyFromParse ¶
func (Money) MarshalYAML ¶
func (*Money) UnmarshalYAML ¶
type Report ¶
type Report struct { Title string ColumnTitles []string ValidateResults ValidateResults }
type SearchItem ¶
type SearchItems ¶
type SearchItems []SearchItem
func (SearchItems) ByIndex ¶
func (s SearchItems) ByIndex(index int) (*SearchItem, error)
func (SearchItems) Match ¶
func (s SearchItems) Match(search string) SearchItems
type TransactionType ¶
type TransactionType int
const ( CreditTransaction TransactionType = iota // Incoming transaction DebitTransaction // Outgoing transaction )
type Validatable ¶
type Validatable interface { Type() string String() string Conditions() Conditions }
Validatable types can be validated.
type ValidateResult ¶
type ValidateResult struct { Element Validatable Conditions Conditions }
ValidateResult contains the result of a validation check.
func (ValidateResult) String ¶
func (v ValidateResult) String() string
func (ValidateResult) TableRows ¶
func (v ValidateResult) TableRows() [][]string
func (ValidateResult) Valid ¶
func (v ValidateResult) Valid() bool
Valid returns true if there were no validation problems.
type ValidateResults ¶
type ValidateResults []ValidateResult
func (ValidateResults) String ¶
func (v ValidateResults) String() string
func (ValidateResults) TableRows ¶
func (v ValidateResults) TableRows() [][]string