Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

runableapp/gowikit

Repository files navigation

goWikit

A command-line tool for quickly fetching Wikipedia summaries, written in Go. Inspired by the wikit Node.js project.

I enjoy the original project, but I don’t like having to install many files just to run a Node.js application. I prefer Go because it allows everything to be statically linked and embedded, producing a single executable with no external dependencies. This project is designed to offer that same convenience and simplicity.

Features

  • Get Wikipedia summaries from the command line
  • Support for multiple languages
  • Interactive disambiguation menu
  • Open articles in browser
  • Configurable line wrapping
  • Cross-platform support
  • gowikit can function as a service, exposing REST APIs.

Installation: for using

  • Grep the binary and put anywhere you want.
  • To run as a service, download service.zip and see the example shell/batch/ini/service files.

Installation: for building

Prerequisites

  • Go 1.21 or later
  • Task

Install Task (optional)

https://taskfile.dev/

# On macOS
brew install go-task
# On Linux
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
# On Windows
scoop install task

Build and Install

Option 1: Using build-local.sh (Recommended for local builds)

# Clone the repository
git clone <repository-url>
cd gowikit
# Build using build-local.sh (uses Taskfile-manual.yml)
./build-local.sh

This will build the binary to dist/gowikit and create dist/service.zip.

Option 2: Manual build

# Clone the repository
git clone <repository-url>
cd gowikit
# Install dependencies
go mod download
# Build the binary
go build -o gowikit main.go
# Install to system (optional)
go install .

Option 3: Using Task

# Install dependencies
task deps
# Build
task build
# Install to system
task install

Usage

Syntax: $ gowikit <query> [-flags]

Quotes are not required for multi-word queries.

To change the default language, edit ~/.config/gowikit.json.

Examples

$ gowikit wikipedia
$ gowikit empire state building
$ gowikit linux -b
$ gowikit jugo -l es --link -a

Flags

Flag Description
--lang langCode
-l langCode
Specify language; langCode is an HTML ISO language code
--all
-a
Print all sections of the article (the full page). Recommended to pipe into a reader e.g. less
--line num Set line wrap length to num
--link Print a link to the full article after the summary
-b Open full Wikipedia article in default browser
--browser browser Open full Wikipedia article in specific browser
-d Open disambiguation CLI menu
-D Open disambiguation page in browser
--version
-v
Print installed version number
--name
-n
Print the name of the program: gowikit

Output

The output will be the paragraphs of the Wikipedia article before the table of contents. Line length is neatly wrapped based on your terminal's window size, with a max of about 80 characters. For example:

$ gowikit arch linux
 Arch Linux (or Arch /ˈɑːrtʃ/) is a Linux distribution for computers based on x86-64
 architectures. Arch Linux is composed predominantly of free and open-source software,
 and supports community involvement. The design approach of the development team
 follows the KISS principle ("keep it simple, stupid") as the general guideline,
 and focuses on elegance, code correctness, minimalism and simplicity, and expects
 the user to be willing to make some effort to understand the system's operation.
 A package manager written specifically for Arch Linux, pacman, is used to install,
 remove and update software packages. Arch Linux uses a rolling release model, such
 that a regular system update is all that is needed to obtain the latest Arch software;
 the installation images released by the Arch team are simply up-to-date snapshots
 of the main system components. Arch Linux has comprehensive documentation in the
 form of a community wiki, called the ArchWiki. The wiki is widely regarded among
 the Linux community and ecosystem for often having the most recent information on
 a specific topic and being applicable beyond Arch Linux.

Development

Using Task

# Show all available tasks
task help
# Run tests
task test
# Format code
task format
# Lint code
task lint
# Run all checks
task check
# Build for multiple platforms
task release
# Development mode
task dev

Manual Commands

# Run with arguments
go run main.go <query>
# Test
go test ./...
# Format
go fmt ./...
# Lint
go vet ./...
# Build
go build -o gowikit main.go

Configuration

The configuration file is stored at ~/.config/gowikit.json:

{
 "lang": "en"
}

Dependencies

  • github.com/manifoldco/promptui - Interactive prompts
  • github.com/schollz/progressbar/v3 - Progress bars
  • github.com/spf13/viper - Configuration management

Differences from Original

This Go version maintains feature parity with the original Node.js wikit, with some improvements:

  • Faster startup time
  • Single binary distribution
  • Better cross-platform support
  • More robust error handling

License

This project is not open source.

For details, please refer to LICENSE.md.

Bugs and Suggestions

Please create an issue in the repository. Thanks!

About

Access Wikipedia from command line.

Resources

License

Stars

Watchers

Forks

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /