Coder Social home page Coder Social logo

wikit's Introduction

wikit

A command line program for getting Wikipedia summaries easily.

Installation

$ npm i wikit -g

Usage

Syntax: $ wikit <query> [-flags]

Quotes are not required for multi-word queries.

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

Examples

$ wikit wikipedia

$ wikit empire state building

$ wikit linux -b

$ wikit 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: wikit

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:

$ wikit 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.

Bugs and Suggestions

Please create an issue here. Thanks!

Support Development

Buy Me A Coffee

wikit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wikit's Issues

debian jessie bash error message

/usr/local/lib/node_modules/wikit/index.js:4
const path = require('path'),
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Floating text?

Would that be possible to provide the output without line breaks, please?

Feature suggestion

Very nice work! I have some suggestions and feature requests:

  1. Perhaps add a -d option for the disambiguation page. Maybe a numbered list to be selected? https://en.wikipedia.org/wiki/Root_(disambiguation)
  2. Similarly adding a -s option for listing the sections so they can be selected. This would be really cool.
  3. Parse (or don't change) any math/equations. It is probably best to leave it as markup. For example wikit polynomial has an equation in the first paragraph. This would also help printing sections, e.g., to get a quick reference to an equation.

Cheers

Language flag not honored in combination with other flags

Wikit does not honor the lang flag when flags like -b, -d or -D are used at the same time. This always opens the English version of the article. Even changing lang default in wikit.json does not change this behaviour. The language I tried this with is German (de). Am I missing something or does this just not work?

Problem with wikit in Kubuntu 18.04

Hello a couple of weeks ago I installed wikit.

The command that I used for the installation was:

sudo npm install wikit -g

The answer shown in the terminal was:

npm WARN deprecated [email protected]: the module is now available as 'css-select'
npm WARN deprecated [email protected]: the module is now available as 'css-what'
/usr/local/bin/wikit -> /usr/local/lib/node_modules/wikit/index.js
+ [email protected]
updated 1 package in 11.638s

I assumed that the program had been installed, but when making a query the result was the following:

argo@argo-desktop:~$ wikit Linux

/usr/local/bin/wikit: línea 2: use strict: orden no encontrada
/usr/local/bin/wikit: línea 4: error sintáctico cerca del elemento inesperado (' /usr/local/bin/wikit: línea 4: const path = require('path'),'

Path issue

/usr/bin/env: ‘node’: No such file or directory

HTML appearing in certain searches

When searching wikit stroop effect some HTML appears. For example:

 <div style="background:#f9f9f9;border:1px solid #666;float:right;width:50%;padding:1em;margin:0
 0 1em 1em;">         Naming the font color of a printed
 word is an easier and quicker task if word meaning and
 font color are congruent.

[suggestion] include command line disambiguation

thanks for creating wikit!

Command line disambiguation interface could be something like sdcv dictionary interface:

Works associated with the musical group ABBA
[0] "Mamma Mia" (song), a 1975 ABBA song
[1] Mamma Mia!, a musical based on ABBA songs, which premiered in London in 1999
[2] Mamma Mia! (film), a 2008 film based on the musical
[3] Mamma Mia! Here We Go Again, 2018 film sequel

Other artists
[4] ¡Mamma Mia!, an album by Mexican pop singer Verónica Castro
[5] "Mama Mia" (In-Grid song), a song by the Italian artist In-Grid
[6] "Mamma Mia" (Kara song), a song by the Korean girl group Kara
[7] Mamma Mia! (SF9 EP)

Crashes when running on macOS

Just installed on macOS on my first search for a linux article wikit crashes

$ sudo npm install wikit -g
npm WARN deprecated [email protected]: the module is now available as 'css-select'
npm WARN deprecated [email protected]: the module is now available as 'css-what'
/usr/local/bin/wikit -> /usr/local/lib/node_modules/wikit/index.js
+ [email protected]
updated 1 package in 3.504s
$ wikit linux
internal/modules/cjs/loader.js:657
    throw err;
    ^

Error: Cannot find module 'inquirer'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15)
    at Function.Module._load (internal/modules/cjs/loader.js:580:25)
    at Module.require (internal/modules/cjs/loader.js:711:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at require.page.data (/usr/local/lib/node_modules/wikit/index.js:170:9)
    at /usr/local/lib/node_modules/wikit/node_modules/node-wikipedia/lib/page.js:32:3
    at Request._callback (/usr/local/lib/node_modules/wikit/node_modules/node-wikipedia/lib/dial.js:32:5)
    at Request.self.callback (/usr/local/lib/node_modules/wikit/node_modules/request/request.js:185:22)
    at Request.emit (events.js:193:13)
    at Request.<anonymous> (/usr/local/lib/node_modules/wikit/node_modules/request/request.js:1161:10)
$ npm --version
6.7.0
$ node --version
v11.13.0
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G3025

macOS Homebrew

Hey

Thanks for your great tool!
Any plans to add to homebrew?

wikidict

Could you write a program to get $words definitions from the Wikidictionary - in many languages - as well? I liked your application so much!
Thx for that.
:)

Wikit process doesn't exit in bash script or in terminal.

I have tried these commands in gnome terminal to pipe the disambiguation results into a file:

wikit rotation -d --line 80 > list.txt

and

wikit rotation -d --line 80 | cat > list.txt

I want to use this in the following script converted to a text file for safe uploading:

diswik.txt

Might you have any idea why the command (on line 13 in the script) keeps running. If I press Ctrl-c the two cli commands and the script terminate successfully!

Thanks!

P.S. I believe I installed wikit with npm, and can't remember for sure whether or not I cloned it from this repository! Sorry!

End cut off of output

$ wikit unix epoch
Unix time (also known as POSIX time or epoch time)[citation needed] is a system
for describing instants in time, defined as the number of seconds that have
elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January
1970, minus the number of leap seconds that have taken place since then. It
is used widely in Unix-like and many other operating systems and file formats.
Because the same timestamp can refer to two distinct instants of time around
a leap second, it is neither a linear measure of time nor a true representation
of UTC. Unix time may be checked on most Unix systems by typing date +%s on
the command line.The 32-bit representation of Unix time will end after the completion
of 2,147,483,647 (231 - 1) seconds from the beginning (00:00:00 1 January 1970),
i.e., on 19 January, 2038 03:14:08 GMT. This is referred to as the "Year 2038
problem" where the 32-bit Unix time will overflow and will take the actual count

Last few words got cut off

Wikipedia Wikipedia page results in error

Searching for the Wikipedia Wikipedia page results in an error:

$ wikit wikipedia
⠙ Searching...TypeError: Cannot read property 'substr' of undefined
    at Object.trunc (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/templates/formatting/format.js:50:20)
    at parseTemplate (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/templates/parse.js:35:30)
    at templates.top.forEach.tmpl (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/templates/index.js:35:12)
    at Array.forEach (<anonymous>)
    at Object.parseTemplates [as templates] (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/templates/index.js:34:17)
    at oneSection (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/02-section/index.js:20:16)
    at Object.parseSections [as section] (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/02-section/index.js:72:13)
    at main (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/01-document/index.js:43:25)
    at pages.map.id (/usr/local/lib/node_modules/wikit/node_modules/wtf_wikipedia/src/_fetch/fetch.js:27:14)
    at Array.map (<anonymous>)
wtf_wikipedia error: TypeError: Cannot read property 'substr' of undefined
wikipedia not found :^(

I did some testing with old versions, and it seems like this error only occurs in versions 4.1.3 and later.

Special:Random does not work

I'm using Wikit with things like no-more-secrets and lolcat to create random walls of text in new and unusual ways. I was using a selection of Wikipedia articles I'd typed in, but got the idea of using Wikipedia's Special:Random feature to try to get random pages. (Details here: https://en.wikipedia.org/wiki/Wikipedia:Special:Random)

Unfortunately, I get an error:

# wikit Special:random
⠙ Searching...wtf_wikipedia error: TypeError: Cannot read property '0' of undefined
Special:random not found :^(

This isn't exactly a vital thing, but I thought I'd post an issue to see if it interests anyone.

Either way, thank you for your interesting tool!

codebase improvement

Hey, I think putting the whole code in one file makes it a bit messy. It would be more maintainable and easy to debug / extend if it was split across multiple sections.

I can submit a PR, if you want ?

wikit AI

this was built in Zsh for Mac but should run fine if you convert (say) to (espeak) the linux -eq of macs "say" command.
also you would have to do something with var1 it's just a voice selection for mac. I use this more than Siri since I Am always working in my terminal. I am about to add him to my headless ubuntu V.M. I was working on my own way to filter the text from a wiki pull when I found this saved me a bunch of time. Thanks

#!/bin/bash
v1="Daniel"
v3="y"
v4="/Users/~/DarwinAi/result"
v5="sleep .5s"
v6=('y' 'Y' 'yes' 'Yes' 'YEs' 'YES' 'yES' 'yeS')
v7=('n' 'N' 'no' 'No' 'NO' 'No')

repeat (){
read -p "What Is/ Are: " v2
say -v $v1 "I Am searching for info on "$v2""
wikit $v2 > $v4"$v2".txt
say -v $v1 -f $v4"$v2".txt;$v5
rm $v4"$v2".txt
}

say -v $v1 "Hello My Name Is Darwin";$v5
say -v $v1 "I Answer Questions In The Form of What Is"

repeat

until [[ $v3 == $v7 ]]
do
say -v $v1 "Do you have another Question"
read -p "y/n: " v3

    if [[ $v3 == "$v6" ]]
       then

          repeat 

       elif [[ $v3 == $v7 ]]
          then
              break
       else
          say -v $v1 "sorry I do not understand"
    fi 

done

say -v $v1 "Goodbye"

Opening in browser does not open in browser over SSH

If I try to open in browser using option -b how the wikit know in which browser to open?

I am trying to search for some term working remotely over SSH. No browser will open. How can I force the wikit to open the link in w3m browser?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.