parse key and value (if any) by splitting on '=' sign (file/dir/all tag has already been trimmed)
(s string)
| 112 | // parse key and value (if any) by splitting on '=' sign |
| 113 | // (file/dir/all tag has already been trimmed) |
| 114 | func (t *transform) parseKeyVal(s string) (err error) { |
| 115 | if !strings.ContainsRune(s, '=') { |
| 116 | err = t.key.Set(s) |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | if t.requiresValue() { |
| 121 | fs.Debugf(nil, "received %v", s) |
| 122 | return errors.New("value is required for " + t.key.String()) |
| 123 | } |
| 124 | return nil |
| 125 | } |
| 126 | split := strings.Split(s, "=") |
| 127 | if len(split) != 2 { |
| 128 | return errors.New("too many values") |
| 129 | } |
| 130 | if split[0] == "" { |
| 131 | return errors.New("key cannot be blank") |
| 132 | } |
| 133 | err = t.key.Set(split[0]) |
| 134 | if err != nil { |
| 135 | return err |
| 136 | } |
| 137 | t.value = split[1] |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | // returns true if this particular algorithm requires a value |
| 142 | func (t *transform) requiresValue() bool { |
no test coverage detected