MCPcopy Index your code
hub / github.com/rclone/rclone / parseKeyVal

Method parseKeyVal

lib/transform/options.go:114–139  ·  view source on GitHub ↗

parse key and value (if any) by splitting on '=' sign (file/dir/all tag has already been trimmed)

(s string)

Source from the content-addressed store, hash-verified

112// parse key and value (if any) by splitting on '=' sign
113// (file/dir/all tag has already been trimmed)
114func (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
142func (t *transform) requiresValue() bool {

Callers 1

parseFunction · 0.80

Calls 4

requiresValueMethod · 0.95
DebugfFunction · 0.92
SetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected