29 stable releases
3.2.5 | Apr 30, 2024 |
---|---|
3.0.1 | Mar 4, 2024 |
2.2.3 | Jan 13, 2024 |
2.2.2 | Nov 1, 2023 |
1.0.1 | May 28, 2023 |
#186 in Command-line interface
110KB
2.5K
SLoC
archwiki-rs 📖
- archwiki-rs 📖
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/lucifayr/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 outputs a styled tree of categories and pages but if you need an easily parsable
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 you make too many requests at once.
archwiki-rs local-wiki -t 8
Application 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 set up completion for ZSH (with 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
Useful info for plugin developers
Manual pages
Every command/sub-command has a manual page that goes into more detail about the technical
details of the command and its behavior. See man archwiki-rs
to get started.
Keep in mind that not all info in the man pages is guaranteed to be correct. If you find any mistakes you are welcome to let me know or to file a PR.
Outputting JSON
For the following commands you can use the --json
and --json-raw
flags to get the
output as easily parseable JSON for your program to use:
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
~12–27MB
~422K SLoC