« back to projects source on github license: BSD-3-Clause Open Source

webcli

A command-line interface to the web.

webcli is a web service that takes a command with optional arguments, and then redirects the request to a corresponding web page. Set it as the default search engine in your browser, and you can do things like gim peacock to search Google Images for peacocks, wp Lady Gaga to take you to the Wikipedia page for Lady Gaga, and tiny http://example.com/ to create a tinyurl link. You can define custom commands, tailored to what you want to do.

webcli uses an OpenSearch description to easily register with browsers.
It was inspired by YubNub.

webcli in action.

Using webcli

To start using webcli, visit its home page with your browser.
I'm hosting a demo version on webcli.moreaux.nl that you can use to try it out.

The home page, showing the various commands, ordered by usage.
Visiting the home page also adds the OpenSearch definition to your browser.

With Chrome, just visit the webcli home page, and Chrome should register it as a search engine. Then, go to Settings » Search Engine » Manage search engines and site search. At the bottom of the page, find the webcli entry, click the three dots on the right side, and choose Make default.

Finding the search engine settings in Chrome.
Making webcli the default search engine in Chrome.

With Firefox, visit the webcli home page, click the URL bar or search bar, find the webcli icon with a little ⊕ on it, and click it. This will register it as a search engine. Next, go to Settings » Search » Default Search Engine, and choose webcli.

Registering webcli as a search engine in Firefox.
Making webcli the default search engine in Firefox.

Installation

webcli is a simple Django project. For various ways how to host Django projects, see their official documentation. webcli's configuration uses a bunch of environment variables starting with WEB_, so modifying settings.py shouldn't be necessary in many cases. It can either read these variables from the environment, or from a .env file somewhere up its path. See env.example for the possible variables.

To quickly get webcli up and running in a development environment, create a folder somewhere appropriate, and in that folder, execute the following commands and visit localhost:8000:

git clone https://github.com/irfinnew/webcli app/
virtualenv venv/
source venv/bin/activate
pip install -r app/requirements.txt
cp app/env.example app/.env
sed -i 's/WEB_DEBUG=False/WEB_DEBUG=True/' app/.env
./app/webcli/manage.py migrate
./app/webcli/manage.py createsuperuser
./app/webcli/manage.py runserver

For running webcli in a production environment, I recommend running the application under an application server such as gunicorn that is proxied from a real web server. webcli comes with a script to start gunicorn in bin/appserver, an example systemd service file in system/webcli.service and an example nginx virtualhost file in system/webcli.nginx. If you use simple logging to a file, you may also want to add a cron job for bin/logrotate.

When running webcli in a production setting, you want to change the following variables in .env:

Managing commands

Visit /admin/ (default path, can be changed with WEB_ADMIN_PATH) on a webcli installation and log in with an admin account to get access to the admin interface. Click on Commands to see an overview of the defined commands. Here you can edit existing commands, delete them, and add new ones.

Admin interface: overview of commands.
Admin interface: editing a command.