Skip to content

Commit

Permalink
Revert "Modifiable lang from env (#8)"
Browse files Browse the repository at this point in the history
This reverts commit 8f68a8e.
  • Loading branch information
sheepla authored Jan 5, 2022
1 parent 8f68a8e commit eb6b406
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,6 @@ You can download executable binaries from the release page.

> [Latest Release](https://github.com/sheepla/fzwiki/releases/latest)
## Configuration

You can change the default language by setting a value in the environment variable `FZWIKI_LANG` .

```bash
FZWIKI_LANG="ja" fzwiki ... # --> search from ja.wikipedia.org instead of en.wikipedia.org
```

If you want to make the setting persistent,
add the following line to your rc file of the shell.

- **bash** (`~/.bashrc`) or **zsh** (~/.zshrc):

```bash
export FZWIKI_LANG="ja"
```

- **fish** (`~/.config/fish/config.fish`):

```fish
set -Ux FZWIKI_LANG ja
```

## LICENSE

[MIT](./LICENSE)
Expand Down
17 changes: 4 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
)

const (
appVersion = "0.0.4"
appName = "fzwiki"
envNameLang = "FZWIKI_LANG"
appVersion = "0.0.4"
appName = "fzwiki"
)

type options struct {
Expand Down Expand Up @@ -70,15 +69,7 @@ func main() {
os.Exit(1)
}

var lang string
if opts.Language == "" {
lang = os.Getenv(envNameLang)
} else {
lang = opts.Language
}

result := searchArticles(strings.Join(args, " "), lang)

result := searchArticles(strings.Join(args, " "), opts.Language)
for i := 0; i < len(result.Query.Search); i++ {
if t, err := html2text(result.Query.Search[i].Title); err == nil {
result.Query.Search[i].Title = t
Expand Down Expand Up @@ -111,7 +102,7 @@ func main() {
}

for _, idx := range choices {
url := createPageURL(result.Query.Search[idx].Title, lang)
url := createPageURL(result.Query.Search[idx].Title, opts.Language)
if opts.Open {
if err := webbrowser.Open(url); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit eb6b406

Please sign in to comment.