Make commands join args with spaces
This patch ensures the following commands join their arguments with spaces to make it easier to interact with: - cf - mkdir - cd - attach - detach - ct - copy - move - save
This commit is contained in:
parent
3ec9fd216d
commit
39307a6fa7
9 changed files with 60 additions and 66 deletions
|
@ -3,6 +3,7 @@ package compose
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc/commands"
|
||||
|
@ -22,20 +23,16 @@ func (Attach) Aliases() []string {
|
|||
}
|
||||
|
||||
func (Attach) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
path := ""
|
||||
if len(args) >= 1 {
|
||||
path = args[0]
|
||||
}
|
||||
|
||||
path := strings.Join(args, " ")
|
||||
return commands.CompletePath(path)
|
||||
}
|
||||
|
||||
func (Attach) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 2 {
|
||||
if len(args) == 1 {
|
||||
return fmt.Errorf("Usage: :attach <path>")
|
||||
}
|
||||
|
||||
path := args[1]
|
||||
path := strings.Join(args[1:], " ")
|
||||
|
||||
path, err := homedir.Expand(path)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,6 +2,7 @@ package compose
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||
|
@ -20,7 +21,6 @@ func (Detach) Aliases() []string {
|
|||
|
||||
func (Detach) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
|
||||
return composer.GetAttachments()
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,8 @@ func (Detach) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
var path string
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
|
||||
if len(args) > 2 {
|
||||
return fmt.Errorf("Usage: :detach [path]")
|
||||
}
|
||||
|
||||
if len(args) == 2 {
|
||||
path = args[1]
|
||||
if len(args) > 1 {
|
||||
path = strings.Join(args[1:], " ")
|
||||
} else {
|
||||
// if no attachment is specified, delete the first in the list
|
||||
atts := composer.GetAttachments()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue