Set custom prefix filter on predictor
This replaces #99. I didn't like that you had to change the filter for all arguments or nothing there. This allows the custom prefix filter to be set in the predictor.
It adds the PrefixFilter interface. When a predictor implements PrefixFilter, it will use the supplied filter instead of the default strings.HasPrefix. A new type PrefixFilteringPredictor is also introduced. It wraps both a Predictor and a PrefixFilter.
Codecov Report
Merging #100 into master will increase coverage by
0.23%. The diff coverage is100%.
@@ Coverage Diff @@
## master #100 +/- ##
========================================
+ Coverage 89.76% 90% +0.23%
========================================
Files 12 13 +1
Lines 879 900 +21
========================================
+ Hits 789 810 +21
Misses 79 79
Partials 11 11
| Impacted Files | Coverage Δ | |
|---|---|---|
| complete.go | 67.64% <100%> (-4.15%) |
:arrow_down: |
| prefixfilter.go | 100% <100%> (ø) |
|
| command.go | 100% <100%> (ø) |
:arrow_up: |
| predict.go | 90.9% <100%> (+7.57%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 2f2ff27...0aa33eb. Read the comment docs.
Thanks for the comments. I am away at a company event this week, so I can’t make any updates immediately. I should be able to address the comments within a week.
I just wanted to let you know so you don’t think this is an abandoned drive-by PR.
@posener, Do you have a suggestion for a better name than PrefixFilter? It was the best name I could think of at the time without reusing any terms that are already in use in the project. I half expected your first bit of feedback to be "That name is awful, you should call it X".
@posener, Do you have a suggestion for a better name than PrefixFilter? It was the best name I could think of at the time without reusing any terms that are already in use in the project. I half expected your first bit of feedback to be "That name is awful, you should call it X".
:-)
I would go with Matcher, as it allows you to do different sorts of matching between the completed word and the completion option.