cani 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +28 -10
- data/lib/cani.rb +33 -23
- data/lib/cani/api.rb +1 -1
- data/lib/cani/api/feature/viewer.rb +2 -2
- data/lib/cani/fzf.rb +10 -4
- data/lib/cani/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7926339d9f9917733a8ed487f6ab2f7dea77ded9b5f2799ee016f09c9e60d570
|
4
|
+
data.tar.gz: 45ca6106004772ff0b1b3facc8040c949c66f776a00809d16d0155da6780b452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe46d75f4614cf82aa0294040aabbb06757f3f356f9d899534013fe1132e7ed2fc5f08d0cd35ace34ba6c4964bac1405d6915be11da9d9ba29a25cded8f4ca4
|
7
|
+
data.tar.gz: 9ba149f0dedad78dedf7f9e00dd472e8a7198e01790b7557262677b8f5d188b9c1747738ce30999f863a33981bf610afee34eba3c91a6f53c6c370f396ac3962
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# Cani
|
1
|
+
# Cani — a [caniuse.com](caniuse.com) tui interface
|
2
2
|
|
3
3
|

|
4
4
|
|
5
5
|
Cani is a small command-line wrapper around the data of [caniuse](https://caniuse.com).
|
6
|
-
It uses [fzf](https://github.com/junegunn/fzf) to display results.
|
6
|
+
It uses [fzf](https://github.com/junegunn/fzf) and [curses](https://github.com/ruby/curses) to display results.
|
7
7
|
This wrapper aims to be easy to use out of the box. To achieve this it ships with completions
|
8
8
|
for `bash`, `fish`, and `zsh`. [Caniuse data (1.7MB)](https://github.com/Fyrd/caniuse/blob/master/data.json) is fetched and updated automatically
|
9
9
|
on a regular interval together with completions.
|
@@ -47,8 +47,8 @@ There are some commented settings that can be adjusted in the `~/.config/cani/co
|
|
47
47
|
Running `cani` without arguments yields the help description.
|
48
48
|
Cani supports the following actions:
|
49
49
|
|
50
|
-
- [`use`](#use) - show browser support for
|
51
|
-
- [`show BROWSER VERSION`](#show) - show feature support based on selected browser / version
|
50
|
+
- [`use [FEATURE]`](#use) - show browser support for selected feature
|
51
|
+
- [`show [BROWSER [VERSION]]`](#show) - show feature support based on selected browser / version
|
52
52
|
- [`help`](#help) - show help
|
53
53
|
- [`version`](#version) - print the version number
|
54
54
|
- [`update`](#update) - force update data and completions
|
@@ -64,6 +64,24 @@ cani use
|
|
64
64
|
Show a list of features with fzf. Features are shown with their current W3C status, percentage of support, title and
|
65
65
|
each individual browser's support on a single row.
|
66
66
|
|
67
|
+
This command may be invoked with a feature and supports <kbd>tab</kbd> completion in `bash`, `zsh` and `fish`:
|
68
|
+
|
69
|
+
```sh
|
70
|
+
cani use box-shadow
|
71
|
+
|
72
|
+
# or:
|
73
|
+
# cani use 'box shadow'
|
74
|
+
# cani use 'boxshadow'
|
75
|
+
```
|
76
|
+
|
77
|
+
The above command will show the following table:
|
78
|
+
|
79
|
+

|
80
|
+
|
81
|
+
The table is responsive and will show browsers that fit in available space, everything else wraps accordingly.
|
82
|
+
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.
|
83
|
+
At the bottom there is a legend that provides an abbreviated status color overview.
|
84
|
+
|
67
85
|
### show
|
68
86
|
|
69
87
|
```sh
|
@@ -75,7 +93,7 @@ Selecting a version shows the final window with feature support for that specifi
|
|
75
93
|
Navigating to the previous window is possible by pressing <kbd>escape</kbd>, this will move you up one level.
|
76
94
|
When <kbd>escape</kbd> is pressed at the browser selection menu, the command will exit.
|
77
95
|
|
78
|
-
This command
|
96
|
+
This command may be invoked with a browser and / or version and supports <kbd>tab</kbd> completion in `bash`, `zsh` and `fish`:
|
79
97
|
|
80
98
|
```sh
|
81
99
|
# show all versions of chrome
|
@@ -133,9 +151,9 @@ After running a `purge`, all that remains is running `gem uninstall cani` to com
|
|
133
151
|
|
134
152
|
Last but not least, all `cani` commands can be piped. This will skip running `fzf` and print uncolored output.
|
135
153
|
|
136
|
-
**use**
|
154
|
+
**use** _(the output of_ `cani use ft-name` _cannot be piped)_
|
137
155
|
```sh
|
138
|
-
cani use |
|
156
|
+
cani use | head -3
|
139
157
|
[rc] 97.11% PNG alpha transparency +chr +ff +edge +ie +saf +saf.ios +op +and +bb
|
140
158
|
[un] 75.85% Animated PNG (APNG) +chr +ff -edge -ie +saf +saf.ios +op -and -bb
|
141
159
|
[ls] 94.32% Video element +chr +ff +edge +ie +saf +saf.ios +op +and +bb
|
@@ -143,7 +161,7 @@ cani use | cat | head -3
|
|
143
161
|
|
144
162
|
**show**
|
145
163
|
```sh
|
146
|
-
cani show |
|
164
|
+
cani show | head -3
|
147
165
|
ie usage: 3.1899%
|
148
166
|
edge usage: 1.8262%
|
149
167
|
firefox usage: 5.0480%
|
@@ -151,7 +169,7 @@ firefox usage: 5.0480%
|
|
151
169
|
|
152
170
|
**show BROWSER**
|
153
171
|
```sh
|
154
|
-
cani show firefox |
|
172
|
+
cani show firefox | head -3
|
155
173
|
63 usage: 0.0000%
|
156
174
|
62 usage: 0.0131%
|
157
175
|
61 usage: 0.2184%
|
@@ -159,7 +177,7 @@ cani show firefox | cat | head -3
|
|
159
177
|
|
160
178
|
**show BROWSER VERSION**
|
161
179
|
```sh
|
162
|
-
cani show firefox 63 |
|
180
|
+
cani show firefox 63 | head -3
|
163
181
|
[rc] [+] PNG alpha transparency
|
164
182
|
[un] [+] Animated PNG (APNG)
|
165
183
|
[ls] [+] Video element
|
data/lib/cani.rb
CHANGED
@@ -40,34 +40,44 @@ module Cani
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.help
|
43
|
-
|
43
|
+
String.disable_colorization true unless STDOUT.tty?
|
44
|
+
puts "Cani ".light_yellow + VERSION.to_s + ' <https://github.com/SidOfc/cani>'.light_black
|
44
45
|
puts ''
|
45
|
-
puts '
|
46
|
+
puts 'This command provides a TUI interface to access caniuse.com data.'.light_black
|
47
|
+
puts 'It allows one to search by browser / version using the \'show\' command'.light_black
|
48
|
+
puts 'and by feature using the \'use\' command. Pressing <enter> on a feature'.light_black
|
49
|
+
puts 'in the \'use\' overview or calling \'use some-feature\' will display a'.light_black
|
50
|
+
puts 'table as seen on caniuse.com using curses.'.light_black
|
46
51
|
puts ''
|
47
|
-
puts '
|
48
|
-
puts '
|
49
|
-
puts '
|
50
|
-
puts '
|
51
|
-
puts '
|
52
|
-
puts '
|
53
|
-
puts '
|
52
|
+
puts 'Usage:'.red
|
53
|
+
puts ' cani'.yellow + ' [COMMAND [ARGUMENTS]]'
|
54
|
+
puts ''
|
55
|
+
puts 'Commands:'.red
|
56
|
+
puts ' use '.blue + ' [FEATURE] ' + 'show browser support for FEATURE'.light_black
|
57
|
+
puts ' show'.blue + ' [BROWSER [VERSION]] ' + 'show information about specific BROWSER and VERSION'.light_black
|
58
|
+
puts ' '
|
59
|
+
puts ' install_completions '.blue + 'installs completions for bash, zsh and fish'.light_black
|
60
|
+
puts ' update '.blue + 'force update api data and completions'.light_black
|
61
|
+
puts ' purge '.blue + 'remove all completion, configuration and data'.light_black
|
62
|
+
puts ' '.blue + 'stored by this cani'.light_black
|
54
63
|
puts ' '
|
55
|
-
puts ' help
|
56
|
-
puts ' version
|
64
|
+
puts ' help '.blue + 'show this help'.light_black
|
65
|
+
puts ' version '.blue + 'print the version number'.light_black
|
57
66
|
puts ''
|
58
|
-
puts 'Examples:'
|
59
|
-
puts ' cani use'
|
60
|
-
puts ' cani
|
61
|
-
puts ' cani show
|
67
|
+
puts 'Examples:'.red
|
68
|
+
puts ' cani'.yellow + ' use'.blue
|
69
|
+
puts ' cani'.yellow + ' use'.blue + ' \'box-shadow\''
|
70
|
+
puts ' cani'.yellow + ' show'.blue + ' ie'
|
71
|
+
puts ' cani'.yellow + ' show'.blue + ' ie 11'
|
62
72
|
puts ''
|
63
|
-
puts 'Statuses:'
|
64
|
-
puts ' [ls] WHATWG Living Standard'
|
65
|
-
puts ' [rc] W3C Recommendation'
|
66
|
-
puts ' [pr] W3C Proposed Recommendation'
|
67
|
-
puts ' [cr] W3C Candidate Recommendation'
|
68
|
-
puts ' [wd] W3C Working Draft'
|
69
|
-
puts ' [
|
70
|
-
puts ' [
|
73
|
+
puts 'Statuses:'.red
|
74
|
+
puts ' [ls]'.green + ' WHATWG Living Standard'.light_black
|
75
|
+
puts ' [rc]'.green + ' W3C Recommendation'.light_black
|
76
|
+
puts ' [pr]'.green + ' W3C Proposed Recommendation'.light_black
|
77
|
+
puts ' [cr]'.green + ' W3C Candidate Recommendation'.light_black
|
78
|
+
puts ' [wd]'.green + ' W3C Working Draft'.light_black
|
79
|
+
puts ' [un]'.yellow + ' Unofficial, Editor\'s draft or W3C "Note"'.light_black
|
80
|
+
puts ' [ot]'.magenta + ' Non-W3C, but reputable'.light_black
|
71
81
|
end
|
72
82
|
|
73
83
|
def self.version
|
data/lib/cani/api.rb
CHANGED
@@ -54,7 +54,7 @@ module Cani
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def find_feature(name)
|
57
|
-
name = Regexp.new name.to_s.downcase.gsub(/(\W)/, '.*')
|
57
|
+
name = Regexp.new name.to_s.downcase.gsub(/(\W)/, '.*'), :i
|
58
58
|
idx = features.find_index do |ft|
|
59
59
|
ft.title.downcase.match?(name) || ft.name.downcase.match?(name)
|
60
60
|
end
|
@@ -9,7 +9,7 @@ module Cani
|
|
9
9
|
69 => [70, -1], # green on default (legend supported, feature status, percentage counter)
|
10
10
|
213 => [214, -1], # orange on default (legend partial, percentage counter)
|
11
11
|
195 => [9, -1], # red on default (legend unsupported, percentage counter)
|
12
|
-
133 => [
|
12
|
+
133 => [13, -1], # magenta on default (legend flag, current feature status)
|
13
13
|
12 => [75, -1], # blue on default (legend prefix)
|
14
14
|
204 => [205, -1], # pink on default (legend polyfill)
|
15
15
|
99 => [8, -1], # gray on default (legend unknown)
|
@@ -19,7 +19,7 @@ module Cani
|
|
19
19
|
70 => [7, 70], # white on green (supported feature)
|
20
20
|
208 => [7, 214], # white on orange (partial feature)
|
21
21
|
196 => [7, 9], # white on red (unsupported feature)
|
22
|
-
134 => [7,
|
22
|
+
134 => [7, 13], # white on magenta (flag features)
|
23
23
|
11 => [7, 75], # white on blue (prefix feature)
|
24
24
|
100 => [7, 8], # white on gray (unknown features)
|
25
25
|
205 => [7, 205], # white on pink (polyfill features)
|
data/lib/cani/fzf.rb
CHANGED
@@ -31,15 +31,16 @@ module Cani
|
|
31
31
|
def self.feature_rows
|
32
32
|
@feature_rows ||= Cani.api.features.map do |ft|
|
33
33
|
pc = format('%.2f%%', ft.percent).rjust 6
|
34
|
+
cl = {'un' => :yellow, 'ot' => :magenta}.fetch ft.status, :green
|
34
35
|
tt = format('%-24s', ft.title.size > 24 ? ft.title[0..23].strip + '..'
|
35
36
|
: ft.title)
|
36
37
|
|
37
|
-
["[#{ft.status}]", pc, tt, *ft.current_support]
|
38
|
+
[{content: "[#{ft.status}]", color: cl}, pc, tt, *ft.current_support]
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
def self.browser_rows
|
42
|
-
Cani.api.browsers.map do |bwsr|
|
43
|
+
@browser_rows ||= Cani.api.browsers.map do |bwsr|
|
43
44
|
[bwsr.title, 'usage: ' + format('%.4f%%', bwsr.usage.values.sum)]
|
44
45
|
end
|
45
46
|
end
|
@@ -54,7 +55,9 @@ module Cani
|
|
54
55
|
Api::Feature::TYPES.flat_map do |(status, type)|
|
55
56
|
if (features = features_by_support.fetch(type[:name], nil))
|
56
57
|
features.map do |feature|
|
57
|
-
|
58
|
+
color = {'un' => :yellow, 'ot' => :magenta}.fetch feature[:status], :green
|
59
|
+
[{content: "[#{feature[:status]}]", color: color},
|
60
|
+
"[#{type[:symbol]}]", feature[:title]]
|
58
61
|
end
|
59
62
|
end
|
60
63
|
end.compact
|
@@ -66,6 +69,7 @@ module Cani
|
|
66
69
|
|
67
70
|
rows.each do |row|
|
68
71
|
row.each.with_index do |column, i|
|
72
|
+
column = column[:content] if column.is_a? Hash
|
69
73
|
col_width = column.size
|
70
74
|
col_widths[i] = col_width if col_width > col_widths[i].to_i
|
71
75
|
end
|
@@ -73,10 +77,12 @@ module Cani
|
|
73
77
|
|
74
78
|
rows.map do |row|
|
75
79
|
row.map.with_index do |col, i|
|
80
|
+
color = col[:color] if col.is_a? Hash
|
81
|
+
col = col[:content] if col.is_a? Hash
|
76
82
|
result = col.to_s.ljust col_widths[i]
|
77
83
|
|
78
84
|
if STDOUT.tty?
|
79
|
-
result.colorize(colors[i] || colors[-1] || :default)
|
85
|
+
result.colorize(color || colors[i] || colors[-1] || :default)
|
80
86
|
.gsub '"', '\"'
|
81
87
|
else
|
82
88
|
result
|
data/lib/cani/version.rb
CHANGED