aboutsummaryrefslogblamecommitdiffstats
path: root/commands/compose/edit.go
blob: 45c55046bb3e6cc8c1cbe27d2ce19540fdf5b14a (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                
                                    
                                         
                                       

 



                              
 
             




                                               

 
                                


                               
                                            
                                                                


                                                               
 
                                                                          
 
                                                 


                          


                                
package compose

import (
	"errors"

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

type Edit struct {
	Edit   bool `opt:"-e"`
	NoEdit bool `opt:"-E"`
}

func init() {
	commands.Register(Edit{})
}

func (Edit) Context() commands.CommandContext {
	return commands.COMPOSE
}

func (Edit) Aliases() []string {
	return []string{"edit"}
}

func (e Edit) Execute(args []string) error {
	composer, ok := app.SelectedTabContent().(*app.Composer)
	if !ok {
		return errors.New("only valid while composing")
	}

	editHeaders := (config.Compose.EditHeaders || e.Edit) && !e.NoEdit

	err := composer.ShowTerminal(editHeaders)
	if err != nil {
		return err
	}
	composer.FocusTerminal()
	return nil
}