Skip to content

Commit

Permalink
Fixing things
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Mar 12, 2020
1 parent efdb12d commit fc66547
Show file tree
Hide file tree
Showing 67 changed files with 5,798 additions and 6,071 deletions.
34 changes: 25 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TODO
clean up parser so multiple spaces aren't tokens or flag em to be ignored
add proximity search "this is"~5 which means they need to be within 5 bytes of each other
add limit to number of results
investigate string match limit
investigate string match limit (might be wrong for unicode insensitive)
JSON endpoint for HTTP
JSON output for cli
Save to disk output
Expand Down
12 changes: 10 additions & 2 deletions processor/worker_summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ package processor
import (
"fmt"
str "github.com/boyter/cs/string"
. "github.com/logrusorgru/aurora"
"github.com/fatih/color"
"github.com/mattn/go-isatty"
"os"
)

type ResultSummarizer struct {
input chan *fileJob
ResultLimit int64
FileReaderWorker *FileReaderWorker
SnippetCount int
NoColor bool
}

func NewResultSummarizer(input chan *fileJob) ResultSummarizer {
return ResultSummarizer{
input: input,
ResultLimit: -1,
SnippetCount: 1,
NoColor: os.Getenv("TERM") == "dumb" || (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())),
}
}

Expand All @@ -39,11 +43,15 @@ func (f *ResultSummarizer) Start() {

fmtBegin := "\033[1;31m"
fmtEnd := "\033[0m"
if f.NoColor {
fmtBegin = ""
fmtEnd = ""
}

documentFrequency := calculateDocumentFrequency(results)

for _, res := range results {
fmt.Printf("%s %s%.3f%s\n", Magenta(res.Location), Magenta("("), Magenta(res.Score), Magenta(")"))
color.Magenta(fmt.Sprintf("%s (%.3f)", res.Location, res.Score))

v3 := extractRelevantV3(res, documentFrequency, int(SnippetLength), "…")[0]

Expand Down
20 changes: 20 additions & 0 deletions vendor/github.com/fatih/color/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

182 changes: 182 additions & 0 deletions vendor/github.com/fatih/color/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc66547

Please sign in to comment.