Cani — a caniuse.com tui interface

cani cli

Cani is a small command-line wrapper around the data of caniuse. It uses fzf and curses to display results. This wrapper aims to be easy to use out of the box. To achieve this it ships with completions for bash, fish, and zsh. Caniuse data (1.7MB) is fetched and updated automatically on a regular interval together with completions.

Installation

Add this line to your application's Gemfile:

gem 'cani'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cani

dependencies

Cani depends on fzf to display most menu's.

Configuration

After installation, running the command (cani) for the first time will create some files and directories:

  • ~/.config/cani/config.yml - default configuration
  • ~/.config/cani/caniuse.json - caniuse api data
  • ~/.config/cani/completions/_cani.bash - bash completion
  • ~/.config/cani/completions/_cani.zsh - zsh completion
  • ~/.config/fish/completions/cani.fish - fish completions

Some existing files will also be modified:

  • ~/.bashrc - A source line to bash completions will be added, or updated if it exists
  • ~/.zshrc - A source line to zsh completions will be added, or updated if it exists

After running the command for the first time, please restart your shell or source your ~/.*rc file to load completions. There are some commented settings that can be adjusted in the ~/.config/cani/config.yml file.

Usage

Running cani without arguments yields the help description. Cani supports the following actions:

use

cani use

Show a list of features with fzf. Features are shown with their current W3C status, percentage of support, title and each individual browser's support on a single row.

This command may be invoked with a feature and supports tab completion in bash, zsh and fish:

cani use box-shadow

# or:
# cani use 'box shadow'
# cani use 'boxshadow'

The above command will show the following table:

Cani use box-shadow support table

The table is responsive and will show browsers that fit in available space, everything else wraps accordingly. The 3-line high era in the middle resembles the "current era" of most used browsers. Browser versions with less than 0.5% usage aren't shown. At the bottom there is a legend that provides an abbreviated status color overview.

show

cani show

Show a list of browsers. Selecting a browser will take you to the versions for that browser. Selecting a version shows the final window with feature support for that specific browser version. Navigating to the previous window is possible by pressing escape, this will move you up one level. When escape is pressed at the browser selection menu, the command will exit.

This command may be invoked with a browser and / or version and supports tab completion in bash, zsh and fish:

# show all versions of chrome
cani show chr

# show all supported features in chrome 70
cani show chr 70

help

cani help

Displays short help for the cani command

version

cani version

Displays the current version e.g: 0.1.0

update

cani update

Force update dataset and completions.

install_completions

cani install_completions

Completions are supported for zsh, bash and fish shells (currently). They are automatically installed upon first invocation of the cani command. This command is only a fallback in case there were any issues with permissions etc..

purge

cani purge

Purges all files created by this command, removing every trace except the executable itself. It will also remove source lines added that pointed to the completions in ~/.zshrc and ~/.bashrc. After running a purge, all that remains is running gem uninstall cani to completely purge it.

edit

cani edit

Edit the configuration file located at ~/.config/cani/config.yml using $EDITOR env variable.

Pipe output

Last but not least, all cani commands can be piped. This will skip running fzf and print uncolored output.

use (the output of cani use ft-name cannot be piped)

cani use | head -3
[rc]   97.11%   PNG alpha transparency       +chr   +ff   +edge   +ie   +saf   +saf.ios   +op   +and   +bb
[un]   75.85%   Animated PNG (APNG)          +chr   +ff   -edge   -ie   +saf   +saf.ios   +op   -and   -bb
[ls]   94.32%   Video element                +chr   +ff   +edge   +ie   +saf   +saf.ios   +op   +and   +bb

show

cani show | head -3
ie                       usage: 3.1899%
edge                     usage: 1.8262%
firefox                  usage: 5.0480%

show BROWSER

cani show firefox | head -3
63    usage: 0.0000%
62    usage: 0.0131%
61    usage: 0.2184%

show BROWSER VERSION

cani show firefox 63 | head -3
[rc]   [+]   PNG alpha transparency
[un]   [+]   Animated PNG (APNG)
[ls]   [+]   Video element

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sidofc/cani. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Cani project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.