Allow no arguments to :cd

I often use the bare `cd` command to get back to my home directory.
This commit is contained in:
Tadeo Kondrak 2019-06-05 00:58:40 -06:00 committed by Drew DeVault
parent eabdcff863
commit 023a2622f9

View file

@ -17,15 +17,17 @@ func init() {
}
func ChangeDirectory(aerc *widgets.Aerc, args []string) error {
if len(args) != 2 {
return errors.New("Usage: cd <directory>")
if len(args) < 1 || len(args) > 2 {
return errors.New("Usage: cd [directory]")
}
cwd, err := os.Getwd()
if err != nil {
return err
}
var target string
if args[1] == "-" {
if len(args) == 1 {
target = "~"
} else if args[1] == "-" {
if previousDir == "" {
return errors.New("No previous folder to return to")
} else {