diff --git a/CHANGELOG.md b/CHANGELOG.md index f5f2174..9e6a534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ * SetColor method in ConsoleWriter is deprecated. Please use SetDisplayAttributes instead. * prompt.Choose shortcut function is deprecated. -* FilterHasPrefix, FilterHasSuffix and FilterContains is deprecated. Move to "github.com/c-bata/go-prompt/filter" package. ## v0.2.1 (2018/02/14) diff --git a/filter.go b/filter.go index 0fac0df..583674a 100644 --- a/filter.go +++ b/filter.go @@ -1,15 +1,11 @@ package prompt -import ( - "strings" -) +import "strings" // Filter is the type to filter the prompt.Suggestion array. -// Deprecated, move to github.com/c-bata/go-prompt/filter package. type Filter func([]Suggest, string, bool) []Suggest // FilterHasPrefix checks whether the string completions.Text begins with sub. -// Deprecated, move to github.com/c-bata/go-prompt/filter package. func FilterHasPrefix(completions []Suggest, sub string, ignoreCase bool) []Suggest { if sub == "" { return completions @@ -32,7 +28,6 @@ func FilterHasPrefix(completions []Suggest, sub string, ignoreCase bool) []Sugge } // FilterHasSuffix checks whether the completion.Text ends with sub. -// Deprecated, move to github.com/c-bata/go-prompt/filter package. func FilterHasSuffix(completions []Suggest, sub string, ignoreCase bool) []Suggest { if sub == "" { return completions @@ -55,7 +50,6 @@ func FilterHasSuffix(completions []Suggest, sub string, ignoreCase bool) []Sugge } // FilterContains checks whether the completion.Text contains sub. -// Deprecated, move to github.com/c-bata/go-prompt/filter package. func FilterContains(completions []Suggest, sub string, ignoreCase bool) []Suggest { if sub == "" { return completions diff --git a/filter/filter.go b/filter/filter.go deleted file mode 100644 index 348c5f8..0000000 --- a/filter/filter.go +++ /dev/null @@ -1,73 +0,0 @@ -package filter - -import ( - "strings" - - "github.com/c-bata/go-prompt" -) - -// HasPrefix checks whether the string completions.Text begins with sub. -func HasPrefix(suggests []prompt.Suggest, sub string, ignoreCase bool) []prompt.Suggest { - if sub == "" { - return suggests - } - if ignoreCase { - sub = strings.ToUpper(sub) - } - - ret := make([]prompt.Suggest, 0, len(suggests)) - for i := range suggests { - c := suggests[i].Text - if ignoreCase { - c = strings.ToUpper(c) - } - if strings.HasPrefix(c, sub) { - ret = append(ret, suggests[i]) - } - } - return ret -} - -// HasSuffix checks whether the completion.Text ends with sub. -func HasSuffix(suggests []prompt.Suggest, sub string, ignoreCase bool) []prompt.Suggest { - if sub == "" { - return suggests - } - if ignoreCase { - sub = strings.ToUpper(sub) - } - - ret := make([]prompt.Suggest, 0, len(suggests)) - for i := range suggests { - c := suggests[i].Text - if ignoreCase { - c = strings.ToUpper(c) - } - if strings.HasSuffix(c, sub) { - ret = append(ret, suggests[i]) - } - } - return ret -} - -// Contains checks whether the completion.Text contains sub. -func Contains(suggests []prompt.Suggest, sub string, ignoreCase bool) []prompt.Suggest { - if sub == "" { - return suggests - } - if ignoreCase { - sub = strings.ToUpper(sub) - } - - ret := make([]prompt.Suggest, 0, len(suggests)) - for i := range suggests { - c := suggests[i].Text - if ignoreCase { - c = strings.ToUpper(c) - } - if strings.Contains(c, sub) { - ret = append(ret, suggests[i]) - } - } - return ret -}