Mercurial > projects > managesieve
comparison managesieve.go @ 4:f9bb517e9447
Return warning messages from the CHECKSCRIPT and PUTSCRIPT commands
author | Guido Berhoerster <guido+managesieve@berhoerster.name> |
---|---|
date | Tue, 27 Oct 2020 17:47:14 +0100 |
parents | 8413916df2be |
children | 75a4ee940f36 |
comparison
equal
deleted
inserted
replaced
3:8413916df2be | 4:f9bb517e9447 |
---|---|
425 return r.resp == responseOk, err | 425 return r.resp == responseOk, err |
426 } | 426 } |
427 | 427 |
428 // PutScript stores the script content with the given name on the server. An | 428 // PutScript stores the script content with the given name on the server. An |
429 // already existing script with the same name will be replaced. | 429 // already existing script with the same name will be replaced. |
430 func (c *Client) PutScript(name, content string) error { | 430 func (c *Client) PutScript(name, content string) (warnings string, err error) { |
431 if !IsNetUnicode(name) { | 431 if !IsNetUnicode(name) { |
432 return ProtocolError("script name must comply with Net-Unicode") | 432 err = ProtocolError("script name must comply with Net-Unicode") |
433 } | 433 return |
434 _, err := c.cmd("PUTSCRIPT", quoteString(name), quoteString(content)) | 434 } |
435 return err | 435 r, err := c.cmd("PUTSCRIPT", quoteString(name), quoteString(content)) |
436 if err != nil { | |
437 return | |
438 } | |
439 if r.code == "WARNINGS" { | |
440 warnings = r.msg | |
441 } | |
442 return | |
436 } | 443 } |
437 | 444 |
438 // ListScripts returns the names of all scripts on the server and the name of | 445 // ListScripts returns the names of all scripts on the server and the name of |
439 // the currently active script. If there is no active script it returns the | 446 // the currently active script. If there is no active script it returns the |
440 // empty string. | 447 // empty string. |
511 return err | 518 return err |
512 } | 519 } |
513 | 520 |
514 // CheckScript checks if the given script contains any errors. This operation | 521 // CheckScript checks if the given script contains any errors. This operation |
515 // is only available if the server conforms to RFC 5804. | 522 // is only available if the server conforms to RFC 5804. |
516 func (c *Client) CheckScript(content string) error { | 523 func (c *Client) CheckScript(content string) (warnings string, err error) { |
517 if !c.SupportsRFC5804() { | 524 if !c.SupportsRFC5804() { |
518 return NotSupportedError("CHECKSCRIPT") | 525 err = NotSupportedError("CHECKSCRIPT") |
519 } | 526 return |
520 _, err := c.cmd("CHECKSCRIPT", quoteString(content)) | 527 } |
521 return err | 528 r, err := c.cmd("CHECKSCRIPT", quoteString(content)) |
529 if err != nil { | |
530 return | |
531 } | |
532 if r.code == "WARNINGS" { | |
533 warnings = r.msg | |
534 } | |
535 return | |
522 } | 536 } |
523 | 537 |
524 // Noop does nothing but contact the server and can be used to prevent timeouts | 538 // Noop does nothing but contact the server and can be used to prevent timeouts |
525 // and to check whether the connection is still alive. This operation is only | 539 // and to check whether the connection is still alive. This operation is only |
526 // available if the server conforms to RFC 5804. | 540 // available if the server conforms to RFC 5804. |