From 39307a6fa7e96641b822ed0a9acb75021dcf7fe9 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Fri, 20 Sep 2019 17:16:29 +0100 Subject: 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 --- commands/ct.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'commands/ct.go') diff --git a/commands/ct.go b/commands/ct.go index 3cae0bd..8b6e8a8 100644 --- a/commands/ct.go +++ b/commands/ct.go @@ -23,9 +23,10 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string { if len(args) == 0 { return aerc.TabNames() } + joinedArgs := strings.Join(args, " ") out := make([]string, 0) for _, tab := range aerc.TabNames() { - if strings.HasPrefix(tab, args[0]) { + if strings.HasPrefix(tab, joinedArgs) { out = append(out, tab) } } @@ -33,22 +34,23 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string { } func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) != 2 { + if len(args) == 1 { return fmt.Errorf("Usage: %s ", args[0]) } - if args[1] == "-" { + joinedArgs := strings.Join(args[1:], " ") + if joinedArgs == "-" { ok := aerc.SelectPreviousTab() if !ok { return errors.New("No previous tab to return to") } } else { - n, err := strconv.Atoi(args[1]) + n, err := strconv.Atoi(joinedArgs) if err == nil { - if strings.HasPrefix(args[1], "+") { + if strings.HasPrefix(joinedArgs, "+") { for ; n > 0; n-- { aerc.NextTab() } - } else if strings.HasPrefix(args[1], "-") { + } else if strings.HasPrefix(joinedArgs, "-") { for ; n < 0; n++ { aerc.PrevTab() } @@ -60,7 +62,7 @@ func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error { } } } else { - ok := aerc.SelectTab(args[1]) + ok := aerc.SelectTab(joinedArgs) if !ok { return errors.New("No tab with that name") } -- cgit v1.2.3