cani 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95f111716af0ddbdcc7341fee4f664ce201f717a0e9eac416f2677149cc641fc
4
- data.tar.gz: f2284ea6bb64a1087e08d618238898a13f0914cf27d31893e0cbdcd5d4c82579
3
+ metadata.gz: 8ff42679497b6da393ca2d601e565ca49d501b76b1367e32dfbb2adf3adee28d
4
+ data.tar.gz: 332bf2512f53057c7cd7cca0009e073c220793b59e125ba9f3fc1c6d0fc98b7e
5
5
  SHA512:
6
- metadata.gz: 01c58a9b40c957fc38c538496cf92fb717f1ab0edc0a79c703964516e294eb442003ba0f21338dd87467e6e14e41a2b4cf18f147f8933b9abf81da92bb92ad66
7
- data.tar.gz: 28ce0494ce59876a5f96ac631461cb43388490e04db11caebe5fc56d9254136043211e3e85cf6167488b3bb92d4c90969994c40addc6557c4e0740a9aa6b4a03
6
+ metadata.gz: 1c15d317bf97d80e28f16912b7dc87d3ee40b5cd3b7780265a69fb233fd966091f9713ecd0ec86e20214976290472086bf94ab6d9571ecd67a8e0db8110d8ac7
7
+ data.tar.gz: 9171b98adfe8438716418044a53aca5f5dc3da5838933302a3280a4b7d326b8aaa603fda6e710981a0fa469cc6a9e411766911b53d5e707af8a59102be960a3b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cani (0.3.0)
4
+ cani (0.4.0)
5
5
  colorize
6
6
  curses
7
7
  json
data/lib/cani/config.rb CHANGED
@@ -14,7 +14,8 @@ module Cani
14
14
 
15
15
  # usage settings
16
16
  'versions' => 1,
17
- 'browsers' => %w[ie edge chrome firefox safari ios_saf opera android bb]
17
+ 'browsers' => %w[ie edge chrome firefox safari ios_saf opera android bb],
18
+ 'navigate' => 'always'
18
19
  }.freeze
19
20
 
20
21
  def initialize(**opts)
@@ -54,6 +55,10 @@ module Cani
54
55
  FileUtils.rm_rf directory if Dir.exist? directory
55
56
  end
56
57
 
58
+ def nav_type?(type)
59
+ navigate == type.to_s
60
+ end
61
+
57
62
  def install!
58
63
  hrs = (DEFAULTS['expire'] / 3600.to_f).round 2
59
64
  days = (hrs / 24.to_f).round 2
@@ -84,16 +89,20 @@ module Cani
84
89
  f << "# the \"source\" key is used to fetch the data required for\n"
85
90
  f << "# this command to work.\n"
86
91
  f << "source: #{source}\n\n"
92
+ f << "# navigating means reopening the previously open window when going back by pressing <escape>\n"
93
+ f << "# or opening the next menu by selecting an entry in fzf with <enter>\n"
94
+ f << "# there are two different navigation modes:\n"
95
+ f << "# * 'always' - always navigate back to the previous menu, exit only at root menu with <escape>\n"
96
+ f << "# * 'forward' - only allow navigating forward and backwards upto the menu that cani was initially open\n"
97
+ f << "navigate: #{navigate}\n\n"
87
98
  f << "# the \"versions\" key defines how many versions of support\n"
88
99
  f << "# will be shown in the \"use\" command\n"
89
- f << "# e.g. `-ie +edge` becomes `--ie ++edge` when this is set to 2, etc..."
100
+ f << "# e.g. `-ie +edge` becomes `--ie ++edge` when this is set to 2, etc...\n"
90
101
  f << "versions: #{versions}\n\n"
91
102
  f << "# the \"browsers\" key defines which browsers are shown\n"
92
103
  f << "# in the \"use\" command\n"
93
104
  f << "browsers:\n"
94
- f << " # enabled:\n"
95
105
  f << browsers.map { |bn| " - #{bn}" }.join("\n") + "\n"
96
- f << " # others:\n"
97
106
  f << (Cani.api.browsers.map(&:name) - browsers).map { |bn| " # - #{bn}" }.join("\n")
98
107
  end
99
108
 
data/lib/cani/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cani
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/cani.rb CHANGED
@@ -28,6 +28,8 @@ module Cani
28
28
  command = command.to_s.downcase.to_sym
29
29
 
30
30
  case command
31
+ when :edit
32
+ edit
31
33
  when :use
32
34
  use args[0]
33
35
  when :show
@@ -49,6 +51,9 @@ module Cani
49
51
  puts 'in the \'use\' overview or calling \'use some-feature\' will display a'.light_black
50
52
  puts 'table as seen on caniuse.com using curses.'.light_black
51
53
  puts ''
54
+ puts 'cani is dependent on fzf (https://github.com/junegunn/fzf) for the interactive TUI to work.'.light_black
55
+ puts 'without fzf, commands can still be piped to get the regular (colorless) output'.light_black
56
+ puts ''
52
57
  puts 'Usage:'.red
53
58
  puts ' cani'.yellow + ' [COMMAND [ARGUMENTS]]'
54
59
  puts ''
@@ -58,6 +63,7 @@ module Cani
58
63
  puts ' '
59
64
  puts ' install_completions '.blue + 'installs completions for bash, zsh and fish'.light_black
60
65
  puts ' update '.blue + 'force update api data and completions'.light_black
66
+ puts ' edit '.blue + 'edit configuration in $EDITOR'.light_black
61
67
  puts ' purge '.blue + 'remove all completion, configuration and data'.light_black
62
68
  puts ' '.blue + 'stored by this cani'.light_black
63
69
  puts ' '
@@ -69,6 +75,7 @@ module Cani
69
75
  puts ' cani'.yellow + ' use'.blue + ' \'box-shadow\''
70
76
  puts ' cani'.yellow + ' show'.blue + ' ie'
71
77
  puts ' cani'.yellow + ' show'.blue + ' ie 11'
78
+ puts ' cani'.yellow + ' show'.blue + ' ie' + ' |'.light_black + ' cat'.yellow
72
79
  puts ''
73
80
  puts 'Statuses:'.red
74
81
  puts ' [ls]'.green + ' WHATWG Living Standard'.light_black
@@ -103,9 +110,11 @@ module Cani
103
110
  end
104
111
 
105
112
  def self.use(feature = nil)
113
+ @use_min_depth ||= feature ? 1 : 0
114
+
106
115
  if feature && (feature = api.find_feature(feature))
107
116
  Api::Feature::Viewer.new(feature).render
108
- use
117
+ use unless config.nav_type?('forward') && @use_min_depth > 0
109
118
  elsif (chosen = Fzf.pick(Fzf.feature_rows,
110
119
  header: 'use] [' + Api::Feature.support_legend,
111
120
  colors: %i[green light_black light_white light_black]))
@@ -121,16 +130,24 @@ module Cani
121
130
  end
122
131
 
123
132
  def self.show(brws = nil, version = nil)
124
- browser = api.find_browser brws
133
+ browser = api.find_browser brws
134
+ @show_min_depth ||= 0 + (browser ? 1 : 0) + (version ? 1 : 0)
125
135
 
126
136
  if browser
127
137
  if version
128
- Fzf.pick Fzf.browser_feature_rows(browser, version),
129
- header: "show:#{browser.title.downcase}:#{version}] [#{Api::Feature.support_legend}",
130
- colors: [:green, :light_black, :light_white]
138
+ chosen = Fzf.pick Fzf.browser_feature_rows(browser, version),
139
+ header: "show:#{browser.title.downcase}:#{version}] [#{Api::Feature.support_legend}",
140
+ colors: [:green, :light_black, :light_white]
131
141
 
132
- show browser.title
142
+ if chosen.any? && (feature = api.find_feature(chosen[2]))
143
+ Api::Feature::Viewer.new(feature).render
144
+ show browser.title, version
145
+ else
146
+ show browser.title
147
+ end
133
148
  else
149
+ exit if config.nav_type?('forward') && @show_min_depth > 1
150
+
134
151
  if (version = Fzf.pick(Fzf.browser_usage_rows(browser),
135
152
  header: [:show, browser.title],
136
153
  colors: %i[white light_black]).first)
@@ -140,6 +157,8 @@ module Cani
140
157
  end
141
158
  end
142
159
  else
160
+ exit if config.nav_type?('forward') && @show_min_depth > 0
161
+
143
162
  browser = api.find_browser Fzf.pick(Fzf.browser_rows,
144
163
  header: [:show],
145
164
  colors: %i[white light_black]).first
@@ -19,7 +19,7 @@ _cani_completions() {
19
19
  COMPREPLY=($(compgen -W "{{features}}" "${COMP_WORDS[COMP_CWORD]}"))
20
20
  ;;
21
21
  *)
22
- COMPREPLY=($(compgen -W "use show help version update purge install_completions" "${COMP_WORDS[COMP_CWORD]}"))
22
+ COMPREPLY=($(compgen -W "use show help version update purge edit install_completions" "${COMP_WORDS[COMP_CWORD]}"))
23
23
  ;;
24
24
  esac
25
25
  }
@@ -39,5 +39,6 @@ complete -f -c cani -n '__fish_cani_needs_command' -a 'help' -d 'Show command he
39
39
  complete -f -c cani -n '__fish_cani_needs_command' -a 'version' -d 'Print the version number'
40
40
  complete -f -c cani -n '__fish_cani_needs_command' -a 'update' -d 'force update api data and completions'
41
41
  complete -f -c cani -n '__fish_cani_needs_command' -a 'purge' -d 'remove all completion, configuration files and data stored by this cani'
42
+ complete -f -c cani -n '__fish_cani_needs_command' -a 'edit' -d 'open configuration in $EDITOR'
42
43
  complete -f -c cani -n '__fish_cani_needs_command' -a 'install_completions' -d 'install completions for bash, zsh and fish'
43
44
  # update purge install_completions
@@ -8,7 +8,7 @@
8
8
  function _cani {
9
9
  local line
10
10
 
11
- _arguments -C "1: :(use show help version update purge install_completions)" \
11
+ _arguments -C "1: :(use show help version update purge edit install_completions)" \
12
12
  "*::arg:->args"
13
13
 
14
14
  case $line[1] in
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidney Liebrand