-
Notifications
You must be signed in to change notification settings - Fork 4
Home
iloa is a command line tool for gaining knowledge. It pretty prints the results in the terminal, and it can also export the results to CSON, JSON, noon, Plist, XML, and YAML.
- Project Status
- Introduction
- Platform
- Installation
- Usage
- Resources
- Contributing
- Gratitude
- Extras
- Completion
- Configuration
- DuckDuckGo Instant Answers
- Engine
- Encyclopedia of Life
- Frequently (or Never) Asked Questions
- Features
- New APIs
- Overlap
- Weather Underground
- Wikipedia
- Wolfram|Alpha
iloa command: completion, comp
Run iloa comp >> ~/.bashrc
, then source ~/.bashrc
to enable shell completion for iloa commands and options.
To Zsh read your bash script, add to ~/.zshrc
:
autoload bashcompinit
bashcompinit
Now run iloa comp >> ~/.zshrc
and source ~/.zshrc
.
iloa can get and set values in the configuration file once it's been initialized. iloa uses the dot-prop library to allow dot notation for nested values. See the FAQ for why I chose noon for the configuration file format.
iloa command: configuration, config, conf
iloa subcommands:
- init, i - Creates configuration file in home directory (~/.iloa.noon)
- get, g - Gets a value for a given key. Accepts dot notation for nested values.
- set, s - Sets a given key to a given value. Accepts dot notation for nested values.
For single values like verbose
you can just do iloa config set verbose true
. For nested properties, use dot notation like so:
$ iloa config get wiki.intro
Option wiki.intro is true.
$ iloa config set wiki.intro true
Set option wiki.intro to true.
By default, the merge option is set to true, so CLI flags will be merged with the configuration from file. If you pass -s|--save with this, the config file will be overwritten with the current flags. If merge is set to false, the config file will always be used and --save won't work. To restore all defaults run iloa config init --force
.
Refer to the noon syntax guide. When editing the configuration file manually, please remember that empty strings are denoted by two pipes: || and 2 or more spaces separate keys from values.
iloa command: duckduckgo, duck, dg
DDG's API provides instant answers to arbitrary searches. In the case of a generalized term, a disambiguation will be returned:
iloa duck tool
Like Wikipedia, parentheses around a classification indicate specific articles, like so:
iloa duck 'Tool (band)'
-
Bangs - DuckDuckGo's API also accepts bang redirects to over 8 thousand sites with a query interface. Example:
iloa duck '!songmeaning Tool'
...redirects to songmeanings.com query for the band Tool.
You can contribute to better instant answers with the DuckDuckHack platform and join the community at duck.co.
- chalk, ora, and yargonaut are used to style the terminal output.
- date-fns manipulates timestamps for rate limiting.
- good-guy-http gets and caches HTTP requests.
- yargs is used for creating the CLI.
- xml2js is used for XML format, and noon is used for all other formats.
From eol.org:
Our knowledge of the many life-forms on Earth - of animals, plants, fungi, protists and bacteria - is scattered around the world in books, journals, databases, websites, specimen collections, and in the minds of people everywhere. Imagine what it would mean if this information could be gathered together and made available to everyone – anywhere – at a moment’s notice.
This dream is becoming a reality through the Encyclopedia of Life.
Learning to use EOL with iloa takes a little work, their API docs should help. Most commands take some kind of data identifier with a numeric value. Output is currently quite verbose, but informative.
iloa command: eol, life
EOL Subcommands:
- collection, collect, col returns all metadata about a particular collection and the items it contains indexed by EOL
- entry, en gives access to a single hierarchy indexed by EOL and its internal relationships
- hierarchy, hier, hi given a hierarchy identifier, this method returns metadata about the hierarchy and lists the root taxa
- info, i ping service status and lists the identifiers for all hierarchies supplied by content partners
- metadata, meta, md returns all metadata about a particular data object (text, image or video) indexed by EOL
- page, pg takes an EOL page identifier and returns the scientific name for that page, and optionally returns information about common names, media (text, images and videos), and references to the hierarchies which recognize the taxon described on the page
- provider, pro, by get the EOL page IDs given a provider's hierarchy_id and the provider's own unique identifier
- search, match, query, se given a value for a specific element (e.g. scientific name=Homo sapiens), returns a paginated list of the EOL pages containing the search term
Not implemented:
- hierarchy_entries_descendants Couldn't find any IDs that gave descendant data
noon, or 'nother ordinary object notation, is a human-readable data format created by monsterkodi. Despite noon being very new, I decided to use it for leximaven's configuration file because it is incredibly terse, even more so than hjson and cson. This is me supporting a young project that I would like to see get wider recognition. It also makes it dead simple to load and save cson, json, plist, and yaml.
Though this tool may be limited in some ways, it is not biased. Knowledge comes in many forms. I encourage you to seek other knowledge outside of this tool. There is no ultimate authority.
- Extensible
- Configuration file in your home directory called
.iloa.noon
- Access configuration settings by passing commands, setting flags, or just editing the configuration file manually
- Sensible command line defaults and aliases
- XML parsing and building with xml2js
- In-memory caching and other neat features handled by good-guy-http, which is based on request
- Save data to CSON, JSON, noon, Plist, XML, and YAML
- Instant Answers and bang redirects from DuckDuckGo
- Most API functions from Encyclopedia of Life
- Alerts, Almanac, Astronomy, Conditions, Forecast, Geolookup, Hourly, Tide, and Webcams from Weather Underground
- Summaries and Full Articles from Wikipedia
- Computations from Wolfram|Alpha
- Automatic rate-limiting for Weather Underground & Wolfram|Alpha
Adding new APIs to iloa is pretty straightforward. Look at the docs for yargs to understand the module format. Wikipedia has the simplest API, so it's a good example of how to implement a new module.
Each module registers a command with yargs. The command string defines the command and arguments. The builder object defines our options. The handler function contains our command logic.
After configuration checks and theme loading, we assemble the URL from the parsed arguments, argv
. good-guy-http
fetches the JSON response. For each piece of data that is printed in the console, the same data is added to the tofile
object. If --out
is specified, this object is passed to tools.outFile
which is then encoded and saved. Finally, if --save
is specified, options are saved to configuration.
There is some overlapping functionality internally between iloa commands and externally between leximaven & iloa.
-
DuckDuckGo Instant Answers often return Wikipedia articles.
-
Wolfram|Alpha can perform many of the same functions that leximaven can, such as definitions, related words, acronyms, anagrams, pattern matching, and rhymes.
iloa command: weather, wunder, wu
More info about weather than you could ever want! See the API docs for detailed info.
- Control what data you get with the --features | -e flag. If you're limited to 10 requests a minute, do
iloa weather -e alerts,almanac,astronomy,conditions,forecast10day,geolookup,hourly10day,tide,webcams KTPF
as one request! - For more about why Weather Underground's BestForecast is often superior to National Weather Service data, see Weather Underground's About our data.
- Much of the data is provided by Personal Weather Stations.
- A list of Airport Codes is useful for some features
- VTEC Info, US Severe Weather Map & Euro Severe Weather Map for Wunderground alerts
Implemented features:
- Alerts
- Almanac
- Astronomy
- Current Conditions
- Forecast
- Forecast 10-day
- Geolookup
- Hourly forecast
- Hourly 10-day
- Tide
- Webcams
Not implemented:
- Current Hurricane
- History
- Planner
- Radar/Satellite
- Yesterday
API Limits:
- 500/day
- 10/minute
iloa command: wikipedia, wiki, wp
A quick-and-dirty way to get just the article summary (flag -i/--intro) or the full article in MediaWiki markup. You could then pipe the MediaWiki markup into something like pandoc. See the API docs for more info.
iloa command: wolfram, wolf, wa
W|A is a computational knowledge engine written in the Wolfram language which is written in Wolfram's Mathematica language. This makes it possible to search complex scientific concepts in free-form natural language. Example:
iloa wolf 'doppler shift'
...returns the formula for calculating the change in pitch based on the formula:
f_o/f_s = c/(c+v_s)
...where f_o/f_s (frequency reduction factor), c is the speed of sound (340.3 m/s) and v_s is the speed of source away from the observer (10 m/s). The results include an image file link for the rendered LaTeX equation and an audio clip of the calculation on a sine wave.
API Limit:
- 2000/month, caching results not allowed.