From bc340d69360f400fe6e227f65c9629cc2c384624 Mon Sep 17 00:00:00 2001 From: gjbae1212 Date: Thu, 20 Feb 2020 21:53:05 +0900 Subject: [PATCH] Fix broken text in window os. --- README.md | 12 +++++++----- cmd/run.go | 14 ++++++++------ go.mod | 2 ++ go.sum | 2 ++ search/searcher.go | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6f91a74..bf5e5fe 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Because github site doesn't officially support to search for it in README. > Notice that **FindGS** makes internally caching db and indexing in local. > Because Github API is limited 5000 per hourly, so it's required something for caching and for searching with higher performance. > And **FindGS** updates cached data an interval of 1 hour when running it. +> **If you have had starred repositories more than 5000**, you should run findgs an interval of 1 hour.(Github API is limited 5000 per hourly) +> As a result, All of starred repositories can store caching db and indexing in local. It's implemented using **Golang**.

@@ -52,10 +54,10 @@ $ brew tap gjbae1212/findgs $ brew install findgs # linux -$ wget https://github.com/gjbae1212/findgs/releases/download/v1.0.1/findgs_1.0.1_Linux_x86_64.tar.gz +$ wget https://github.com/gjbae1212/findgs/releases/download/v1.0.2/findgs_1.0.2_Linux_x86_64.tar.gz # window -$ wget https://github.com/gjbae1212/findgs/releases/download/v1.0.1/findgs_1.0.1_Windows_x86_64.tar.gz +$ wget https://github.com/gjbae1212/findgs/releases/download/v1.0.2/findgs_1.0.2_Windows_x86_64.tar.gz ```
@@ -79,14 +81,14 @@ $ findgs run -t your-github-token **1. search** This command searches your starred repositories using input text. Also it's to support wildcard searching. ```bash ->> search +>> search [searhing text(ex cli tool, hello* ...)] ``` **2. open** This command show your selected repository to browser. ```bash ->> open name ->> open num +>> open name [searched repositories name] +>> open num [searched column num] ``` **3. list** diff --git a/cmd/run.go b/cmd/run.go index 2a13158..a08b114 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -8,10 +8,12 @@ import ( "strings" "time" - prompt "github.com/c-bata/go-prompt" "github.com/briandowns/spinner" + "github.com/inancgumus/screen" + prompt "github.com/c-bata/go-prompt" "github.com/fatih/color" "github.com/gjbae1212/findgs/search" + "github.com/mattn/go-colorable" "github.com/olekukonko/tablewriter" "github.com/pkg/browser" "github.com/spf13/cobra" @@ -76,8 +78,8 @@ func preRun() execCommand { func run() execCommand { return func(cmd *cobra.Command, args []string) { - fmt.Println("\033[2J") - fmt.Print("\033[H") + screen.Clear() + screen.MoveTopLeft() total, _ := searcher.TotalDoc() color.Green("Indexing %d", total) color.Green("Searching repositories equal to or higher %.3f score", minScore) @@ -256,13 +258,13 @@ func executor(t string) { func showSearchedList() { // clear terminal. - fmt.Println("\033[2J") - fmt.Print("\033[H") + screen.Clear() + screen.MoveTopLeft() color.Green("[search][text] \"%s\"", recentlySearchKeyword) fmt.Println() // table writer - table := tablewriter.NewWriter(os.Stdout) + table := tablewriter.NewWriter(colorable.NewColorableStdout()) table.SetHeader([]string{"NUM", "SCORE", "NAME", "URL", "TOPIC", "DESCRIPTION"}) table.SetFooter([]string{"", "", "", "", "TOTAL", fmt.Sprintf("%d", len(foundList))}) table.SetBorder(false) diff --git a/go.mod b/go.mod index b43a7a6..0c053f5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,9 @@ require ( github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect github.com/fatih/color v1.9.0 github.com/google/go-github/v29 v29.0.3 + github.com/inancgumus/screen v0.0.0-20190314163918-06e984b86ed3 github.com/jmhodges/levigo v1.0.0 // indirect + github.com/mattn/go-colorable v0.1.4 github.com/mattn/go-runewidth v0.0.8 // indirect github.com/mattn/go-tty v0.0.3 // indirect github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index ed83af2..829b303 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,8 @@ github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDG github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/inancgumus/screen v0.0.0-20190314163918-06e984b86ed3 h1:fO9A67/izFYFYky7l1pDP5Dr0BTCRkaQJUG6Jm5ehsk= +github.com/inancgumus/screen v0.0.0-20190314163918-06e984b86ed3/go.mod h1:Ey4uAp+LvIl+s5jRbOHLcZpUDnkjLBROl15fZLwPlTM= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= diff --git a/search/searcher.go b/search/searcher.go index b3a882d..c9bd8f6 100644 --- a/search/searcher.go +++ b/search/searcher.go @@ -278,7 +278,7 @@ func (s *searcher) CreateIndex() error { newStarred.FullName, newStarred.PushedAt.Format(time.RFC3339)) } else { if oldStarred.PushedAt.Unix() != newStarred.PushedAt.Unix() && - oldStarred.CachedAt.Unix() < time.Now().Add(-24*time.Hour).Unix() { + oldStarred.CachedAt.Unix() < time.Now().Add(-24*7*time.Hour).Unix() { // after 7 days. updateList = append(updateList, newStarred) color.White("[update] %s repository pushed_at %s", newStarred.FullName, newStarred.PushedAt.Format(time.RFC3339))