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.
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.
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.
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.
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
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
All contributions are welcome! See CONTRIBUTING for more info.
The code is under the MIT license. See LICENSE for more information.
The code is written by Fredrik Wallgren - https://github.com/walle