Compare commits

..

1 commit

Author SHA1 Message Date
8bd1adca82
Add add verb and message subcommand 2021-04-07 18:24:28 +02:00
2 changed files with 12 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"git.sr.ht/~blallo/papero/cli"
@ -56,8 +57,8 @@ func (pm PutMessageCmd) Func(args []string) error {
var opts imaputils.PutMessageOpts
var err error
var bodyReader io.Reader
var messageTime cli.AbsTimeFlag
var flagSeen, flagAnswered, flagFlagged, flagDeleted, flagDraft bool
var messageTime = cli.NewAbsTimeFlag()
if Session.Info.Opts.Debug {
Log.Debug("enter add message")
}
@ -104,6 +105,8 @@ func (pm PutMessageCmd) Func(args []string) error {
opts.Time = *messageTime.Time
Log.Debugf("Opts: %+v\n", opts)
imaputils.PutMessage(Session.Config, &opts)
return nil
@ -116,14 +119,14 @@ func (pm PutMessageCmd) Help(w io.Writer, set *flag.FlagSet) {
}
func readIntoBuffer(r io.Reader) (*bytes.Buffer, error) {
var b []byte
var empty bytes.Buffer
_, err := io.ReadFull(r, b)
b, err := ioutil.ReadAll(r)
if err != nil {
return &empty, err
}
Log.Debugf("content %+v\n", b)
buff := bytes.NewBuffer(b)
return buff, nil
}

View file

@ -90,6 +90,12 @@ type AbsTimeFlag struct {
*time.Time
}
func NewAbsTimeFlag() AbsTimeFlag {
return AbsTimeFlag{
Time: &time.Time{},
}
}
func (t AbsTimeFlag) String() string {
return fmt.Sprint(t.Time)
}