Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft committed Feb 4, 2017
1 parent d733db2 commit be00546
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ MIT
## Credits
Library | Use
------- | -----
[github.com/flynn/go-shlex](http://github.com/flynn/go-shlex) | splitting input into command and args.
[github.com/flynn-archive/go-shlex](http://github.com/flynn-archive/go-shlex) | splitting input into command and args.
[gopkg.in/readline.v1](http://gopkg.in/readline.v1) | history, tab completion and reading passwords.

## Donate
Expand Down
15 changes: 13 additions & 2 deletions completer.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package ishell

import "strings"
import (
"strings"

"github.com/flynn-archive/go-shlex"
)

type iCompleter struct {
cmd *Cmd
}

func (ic iCompleter) Do(line []rune, pos int) (newLine [][]rune, length int) {
words := strings.Fields(string(line))
var words []string
if w, err := shlex.Split(string(line)); err == nil {
words = w
} else {
// fall back
words = strings.Fields(string(line))
}

var cWords []string
prefix := ""
if len(words) > 0 && line[pos-1] != ' ' {
Expand Down
5 changes: 3 additions & 2 deletions ishell.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"sync"

"github.com/flynn/go-shlex"
"github.com/flynn-archive/go-shlex"
"gopkg.in/readline.v1"
)

Expand Down Expand Up @@ -111,6 +111,7 @@ shell:
break
} else if err != nil && err != readline.ErrInterrupt {
s.Println("Error:", err)
continue
}

if err == readline.ErrInterrupt {
Expand Down Expand Up @@ -267,7 +268,7 @@ func (s *Shell) initCompleters() {
func (s *Shell) setCompleter(completer readline.AutoCompleter) {
var err error
// close current scanner and rebuild it with
// command in autocomplete
// autocomplete
s.reader.scanner.Close()
config := s.reader.scanner.Config
config.AutoComplete = completer
Expand Down

0 comments on commit be00546

Please sign in to comment.