diff --git a/cmd/client/list.go b/cmd/client/list.go index cc3efe6..b7502a9 100644 --- a/cmd/client/list.go +++ b/cmd/client/list.go @@ -9,9 +9,7 @@ import ( "github.com/inbucket/inbucket/v3/pkg/rest/client" ) -type listCmd struct { - mailbox string -} +type listCmd struct{} func (*listCmd) Name() string { return "list" @@ -27,8 +25,7 @@ func (*listCmd) Usage() string { ` } -func (l *listCmd) SetFlags(f *flag.FlagSet) { -} +func (l *listCmd) SetFlags(f *flag.FlagSet) {} func (l *listCmd) Execute( _ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { diff --git a/cmd/client/main.go b/cmd/client/main.go index 48828fe..7ea2867 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -50,14 +50,17 @@ func main() { // Important top-level flags subcommands.ImportantFlag("host") subcommands.ImportantFlag("port") + // Setup standard helpers subcommands.Register(subcommands.HelpCommand(), "") subcommands.Register(subcommands.FlagsCommand(), "") subcommands.Register(subcommands.CommandsCommand(), "") + // Setup my commands subcommands.Register(&listCmd{}, "") subcommands.Register(&matchCmd{}, "") subcommands.Register(&mboxCmd{}, "") + // Parse and execute flag.Parse() ctx := context.Background() diff --git a/cmd/client/match.go b/cmd/client/match.go index f648022..2f8a6ca 100644 --- a/cmd/client/match.go +++ b/cmd/client/match.go @@ -14,7 +14,6 @@ import ( ) type matchCmd struct { - mailbox string output string outFunc func(headers []*client.MessageHeader) error delete bool diff --git a/cmd/client/mbox.go b/cmd/client/mbox.go index 946e6ab..38ebd7b 100644 --- a/cmd/client/mbox.go +++ b/cmd/client/mbox.go @@ -11,8 +11,7 @@ import ( ) type mboxCmd struct { - mailbox string - delete bool + delete bool } func (*mboxCmd) Name() string { @@ -73,9 +72,12 @@ func outputMbox(headers []*client.MessageHeader) error { if err != nil { return fmt.Errorf("Get source REST failed: %v", err) } + fmt.Printf("From %s\n", h.From) // TODO Escape "From " in message bodies with > - source.WriteTo(os.Stdout) + if _, err := source.WriteTo(os.Stdout); err != nil { + return err + } fmt.Println() } return nil