#cli #arch-wiki

app archwiki-rs

A CLI tool to read pages from the ArchWiki

19 stable releases

3.0.0 Jan 26, 2024
2.2.3 Jan 13, 2024
2.2.2 Nov 1, 2023
2.2.1 Sep 11, 2023
1.0.1 May 28, 2023

#76 in Command-line interface

Download history 2/week @ 2023-11-11 59/week @ 2023-11-18 54/week @ 2023-11-25 35/week @ 2023-12-02 18/week @ 2023-12-16 34/week @ 2023-12-23 2/week @ 2023-12-30 20/week @ 2024-01-06 39/week @ 2024-01-13 26/week @ 2024-01-20 81/week @ 2024-01-27 2/week @ 2024-02-03 64/week @ 2024-02-10 533/week @ 2024-02-17 452/week @ 2024-02-24

1,051 downloads per month

MIT and GPL-3.0+

65KB
1.5K SLoC

archwiki-rs 📖

A CLI tool to read pages from the ArchWiki

Installation

Currently, you can only install this tool from crates.io or build it from source.

After installation you might want to run the sync-wiki command.

crates.io

cargo install archwiki-rs

Source


git clone https://gitlab.com/Jackboxx/archwiki-rs
cd archwiki-rs
cargo install --path .

Usage

Reading Pages

Basic request

archwiki-rs read-page Neovim

Using a different format

archwiki-rs read-page Neovim --format markdown

Caching

By default, pages are cached in the file system after they are fetched and subsequent request for that page then use that cache. The cache is invalidated if the cached file hasn't been modified in the last 14 days.

404 page not found (-̥̥̥n-̥̥̥ )

If the page you are searching for doesn't exist, a list of the pages that are most similar (in name) to the page you asked for will be output instead of the page content

archwiki-rs read-page Neovi

# output
Neovim
...

Unlike the output when the page name does exist, this output is written to stderr instead of stdout. If you want to, you can create a program that checks if no page was found and uses stderr to give the user suggestions on what they might have wanted to type.

An example shell script to do something like this is available in the repository under the name example.sh which can be used like this sh example.sh <page-name>.

Searching the ArchWiki

Search by title

archwiki-rs search "Emacs"

This returns a table of pages with a similar title and their URLs

Search for text

archwiki-rs search "shell" -t

This returns a table of pages which contain the search term and the snippet of text that the search term is in

Downloading wiki info

Page and category names are stored locally for faster look-ups. Use this command to fetch all page and category names.

archwiki-rs sync-wiki

Listing ArchWiki information

Listing pages

archwiki-rs list-pages

This is output a styled tree of categories and pages but if you need an easily parseable list for a different program to use, you can use the -f flag to flatten the output into a newline separated list that only contains the names of all pages

archwiki-rs list-pages -f

You can also limit the list to only include pages that belong to a specific category

archwiki-rs list-pages -c "Xorg commands"

Listing categories

To do the same for categories you can run

archwiki-rs list-categories

Listing languages

And the same for available languages

archwiki-rs list-languages

Downloading a local copy of the ArchWiki

Use this command to download a local copy of the ArchWiki. Be warned, this command makes over 10,000 requests to the ArchWiki so it takes a while to finish (-, -)…zzzZZ

archwiki-rs local-wiki ~/local-archwiki --format markdown

Possible speed-ups

If you don't mind your CPU and network becoming a bit saturated you can increase the amount of threads used to fetch data from the wiki.

Keep in mind that you might get rate limited by the ArchWiki if make too many requests at once.

archwiki-rs local-wiki -t 8

Other Information

Other information such as the value/location of the cache directory can be obtained using the info command

archwiki-rs info

To only get the value of an entry and not the name and description that belong to it you can use the -o flag

archwiki-rs info -o

Setup shell completion

You can generate a completion file to allow tab completion for most popular shells (list of supported shells).

The following example shows how to setup completion for ZSH (with the oh my zsh).

archwiki-rs completions > /home/iusearchbtw/.oh-my-zsh/completions/_archwiki-rs

Plugins

Here's a list of programs that have plugins for archwiki-rs to make your life easier

Alternatives

If you are using Arch Linux a great alternative for this tool is the wikiman CLI tool in combination with the arch-wiki-docs package.

Dependencies

~23–41MB
~679K SLoC