MCPcopy
hub / github.com/kashav/fsql / Format

Function Format

transform/format.go:26–48  ·  view source on GitHub ↗

Format runs the respective format function on the provided parameters.

(p *FormatParams)

Source from the content-addressed store, hash-verified

24
25// Format runs the respective format function on the provided parameters.
26func Format(p *FormatParams) (val interface{}, err error) {
27 switch strings.ToUpper(p.Name) {
28 case "FORMAT":
29 val, err = p.format()
30 case "UPPER":
31 val = upper(p.Value.(string))
32 case "LOWER":
33 val = lower(p.Value.(string))
34 case "FULLPATH":
35 val, err = p.fullPath()
36 case "SHORTPATH":
37 val, err = p.shortPath()
38 case "SHA1":
39 val, err = p.hash(FindHash(p.Name)())
40 }
41 if err != nil {
42 return nil, err
43 }
44 if val == nil {
45 return nil, &ErrNotImplemented{p.Name, p.Attribute}
46 }
47 return val, nil
48}
49
50// format runs a format function based on the value of the provided attribute.
51func (p *FormatParams) format() (val interface{}, err error) {

Callers 2

applyModifiersMethod · 0.92
TestTransform_FormatFunction · 0.85

Calls 7

upperFunction · 0.85
lowerFunction · 0.85
FindHashFunction · 0.85
fullPathMethod · 0.80
shortPathMethod · 0.80
formatMethod · 0.45
hashMethod · 0.45

Tested by 1

TestTransform_FormatFunction · 0.68