Skip to content

underyx/wiki

 
 

Repository files navigation

Build Status Godoc license Go Report Card

wiki

Command line tool to get Wikipedia summaries.

The tool can fetch summaries from any Mediawiki wiki with the API active, but defaults to the English Wikipedia.

Installation

To be able to install with go get requires you to have your $GOPATH setup and your $GOPATH/bin added to path as described here http://golang.org/doc/code.html#GOPATH.

If you don't want the man file you can just install it with go get.

$ go get github.com/walle/wiki/cmd/wiki

If you want to install the man file you can install with go get, but then use the make install command from the source directory.

$ go get github.com/walle/wiki
$ cd $GOPATH/src/github.com/walle/wiki
$ make install

or just copy the man file in _doc/wiki.1 to /usr/local/share/man/man1 or where you keep your man files.

Usage

To get a summary from Wikipedia in English just invoke the tool with a query.

$ wiki golang

To get a localized result, e.g. in Swedish use the -l flag.

$ wiki -l sv ruby

Use the -h flag to see all options (or man wiki if you have it installed)

$wiki -h
wiki is a tool used to fetch exerpts from wikipedia
Usage: wiki [options...] query
Options:

  -h    Print help information and exit.
  -l string
        The language to use (default "en")
  -n    If the output should not be colorized
  -s    If simple output should be used
  -u string
        The api url (default "https://%s.wikipedia.org/w/api.php")
  -version
        Print version information and exit.

Use another wiki

To get excerpts from another wiki use the -u flag to give another url to the API to use.

$ wiki -u https://en.wikiversity.org/w/api.php physics

This gives the excerpt from the wiki at wikiversity.org instead of Wikipedia.

Advice

If you frequently use the tool to fetch data from a custom url, add an alias. E.g. for bash. Add an alias to your .bash_profile or .bashrc file.

alias uwiki='wiki -u https://en.wikiversity.org/w/api.php '

And call it using

$ uwiki physics

Testing

Run the tests using the make target test make test, this runs both the unit and the integration tests. For running only one type of tests use go test -cover and ./integration-tests.sh respectively.

$ make test

Contributing

All contributions are welcome! See CONTRIBUTING for more info.

License

The code is under the MIT license. See LICENSE for more information.

Authors

The code is written by Fredrik Wallgren - https://github.com/walle

About

Command line tool to fetch summaries from mediawiki wikis, like Wikipedia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 58.0%
  • Shell 20.0%
  • Roff 12.2%
  • Makefile 9.8%