aboutsummaryrefslogblamecommitdiffstats
path: root/commands/account/expand-folder.go
blob: 29203adc22c18fad782d21d92e254dc8b0ae4a1f (plain) (tree)
1
2
3
4
5
6
7





                
                                    











                                                           
                                                              


                  
                                                          


                                                         
                                     













                                                        
package account

import (
	"errors"
	"fmt"

	"git.sr.ht/~rjarry/aerc/app"
)

type ExpandCollapseFolder struct{}

func init() {
	register(ExpandCollapseFolder{})
}

func (ExpandCollapseFolder) Aliases() []string {
	return []string{"expand-folder", "collapse-folder"}
}

func (ExpandCollapseFolder) Complete(args []string) []string {
	return nil
}

func (ExpandCollapseFolder) Execute(args []string) error {
	if len(args) > 1 {
		return expandCollapseFolderUsage(args[0])
	}
	acct := app.SelectedAccount()
	if acct == nil {
		return errors.New("No account selected")
	}
	if args[0] == "expand-folder" {
		acct.Directories().ExpandFolder()
	} else {
		acct.Directories().CollapseFolder()
	}
	return nil
}

func expandCollapseFolderUsage(cmd string) error {
	return fmt.Errorf("Usage: %s", cmd)
}