2019-05-19 20:00:02 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os"
|
2020-05-28 16:32:32 +02:00
|
|
|
"time"
|
2019-05-19 20:00:02 +02:00
|
|
|
|
|
|
|
"git.sr.ht/~sircmpwn/aerc/widgets"
|
|
|
|
)
|
|
|
|
|
2019-06-27 19:33:11 +02:00
|
|
|
type PrintWorkDir struct{}
|
|
|
|
|
2019-05-19 20:00:02 +02:00
|
|
|
func init() {
|
2019-06-27 19:33:11 +02:00
|
|
|
register(PrintWorkDir{})
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (PrintWorkDir) Aliases() []string {
|
2019-06-27 19:33:11 +02:00
|
|
|
return []string{"pwd"}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (PrintWorkDir) Complete(aerc *widgets.Aerc, args []string) []string {
|
2019-06-27 19:33:11 +02:00
|
|
|
return nil
|
2019-05-19 20:00:02 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (PrintWorkDir) Execute(aerc *widgets.Aerc, args []string) error {
|
2019-05-19 20:00:02 +02:00
|
|
|
if len(args) != 1 {
|
|
|
|
return errors.New("Usage: pwd")
|
|
|
|
}
|
|
|
|
pwd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-05-28 16:32:32 +02:00
|
|
|
aerc.PushStatus(pwd, 10*time.Second)
|
2019-05-19 20:00:02 +02:00
|
|
|
return nil
|
|
|
|
}
|