Compare commits
1 commit
5ced6729ce
...
8bd1adca82
Author | SHA1 | Date | |
---|---|---|---|
8bd1adca82 |
2 changed files with 12 additions and 3 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.sr.ht/~blallo/papero/cli"
|
"git.sr.ht/~blallo/papero/cli"
|
||||||
|
@ -56,8 +57,8 @@ func (pm PutMessageCmd) Func(args []string) error {
|
||||||
var opts imaputils.PutMessageOpts
|
var opts imaputils.PutMessageOpts
|
||||||
var err error
|
var err error
|
||||||
var bodyReader io.Reader
|
var bodyReader io.Reader
|
||||||
var messageTime cli.AbsTimeFlag
|
|
||||||
var flagSeen, flagAnswered, flagFlagged, flagDeleted, flagDraft bool
|
var flagSeen, flagAnswered, flagFlagged, flagDeleted, flagDraft bool
|
||||||
|
var messageTime = cli.NewAbsTimeFlag()
|
||||||
if Session.Info.Opts.Debug {
|
if Session.Info.Opts.Debug {
|
||||||
Log.Debug("enter add message")
|
Log.Debug("enter add message")
|
||||||
}
|
}
|
||||||
|
@ -104,6 +105,8 @@ func (pm PutMessageCmd) Func(args []string) error {
|
||||||
|
|
||||||
opts.Time = *messageTime.Time
|
opts.Time = *messageTime.Time
|
||||||
|
|
||||||
|
Log.Debugf("Opts: %+v\n", opts)
|
||||||
|
|
||||||
imaputils.PutMessage(Session.Config, &opts)
|
imaputils.PutMessage(Session.Config, &opts)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -116,14 +119,14 @@ func (pm PutMessageCmd) Help(w io.Writer, set *flag.FlagSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readIntoBuffer(r io.Reader) (*bytes.Buffer, error) {
|
func readIntoBuffer(r io.Reader) (*bytes.Buffer, error) {
|
||||||
var b []byte
|
|
||||||
var empty bytes.Buffer
|
var empty bytes.Buffer
|
||||||
|
|
||||||
_, err := io.ReadFull(r, b)
|
b, err := ioutil.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &empty, err
|
return &empty, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.Debugf("content %+v\n", b)
|
||||||
buff := bytes.NewBuffer(b)
|
buff := bytes.NewBuffer(b)
|
||||||
return buff, nil
|
return buff, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,12 @@ type AbsTimeFlag struct {
|
||||||
*time.Time
|
*time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewAbsTimeFlag() AbsTimeFlag {
|
||||||
|
return AbsTimeFlag{
|
||||||
|
Time: &time.Time{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (t AbsTimeFlag) String() string {
|
func (t AbsTimeFlag) String() string {
|
||||||
return fmt.Sprint(t.Time)
|
return fmt.Sprint(t.Time)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue