Skip to content

Commit

Permalink
Add: HOWDOI_URL_REGEX env set
Browse files Browse the repository at this point in the history
  • Loading branch information
chinanf-boy committed Nov 20, 2018
1 parent a44e355 commit 1eecd08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pkg/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
answerHeader string
noAnswerMsg string
searchEngine string
uRLRegexText string
)

const allSearchEngine = "ALL"
Expand All @@ -29,6 +30,7 @@ func init() {
}
uRL = getEnv("HOWDOI_URL", "stackoverflow.com")
searchEngine = getEnv("HOWDOI_SEARCH_ENGINE", allSearchEngine)
uRLRegexText = getEnv("HOWDOI_URL_REGEX", `questions/\d+/`)

searchUrls = map[string]string{
"bing": scheme + "www.bing.com/search?q=%s site:%s",
Expand Down
2 changes: 1 addition & 1 deletion pkg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func cutURL(links []string) []string {
return links
}
func isQuestion(s string) bool {
m := isRegexp(s, `questions/\d+/`)
m := isRegexp(s, uRLRegexText)

return m
}
Expand Down
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## howdoi [![Build Status](https://travis-ci.org/chinanf-boy/howdoi.svg)](https://travis-ci.org/chinanf-boy/howdoi)
## howdoi [![Build Status](https://travis-ci.org/chinanf-boy/howdoi.svg)](https://travis-ci.org/chinanf-boy/howdoi)

Copy from [howdoi:py](https://github.com/gleitz/howdoi), But Faster

Expand All @@ -15,7 +15,7 @@ go get -v -u github.com/chinanf-boy/howdoi
same as py:howdoi , but lit diff

```bash
$ howdoi -q "format date bash" -c -C
$ howdoi -q "format date bash" -c -C
```

![demo](./demo.png)
Expand Down Expand Up @@ -44,6 +44,7 @@ About the `ENV`
| ------------------------ | ---------------------------------- | --------------------- |
| **HOWDOI_DISABLE_SSL** | change `https://` => `http://` | `nil` |
| **HOWDOI_URL** | search engine with the ask website | `stackoverflow.com` |
| **HOWDOI_URL_REGEX** | match the regex with URL | `questions/\d+/` |
| **HOWDOI_SEARCH_ENGINE** | search engine{`bing`\|`google`} | `ALL` |
| **HOWDOI_CACHE_DIR** | http Response - Cached dir | `$HOME/.howdoi-cache` |
| **-T** | [chroma theme](#chroma-theme) | `pygments` |
Expand All @@ -58,7 +59,7 @@ About the `ENV`

<details>

<summary> info </summary>
<summary> themes >> </summary>

```go
[
Expand Down

0 comments on commit 1eecd08

Please sign in to comment.