snibbets 2.0.21 → 2.0.23

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: d8faa764639ff4c20cf7527936e4b4f8c5338bebda2a1711150bf395ea9731bf
4
- data.tar.gz: 50dca9964625bc96e539818cf650d295f568b0870742d156bd3036f2d9847738
3
+ metadata.gz: f4b84e73a8183169220197b680d511137b7aa5e191f22df4a4d8bc30217b9835
4
+ data.tar.gz: 6add8e505ca052e703c79aa43f99b2b58a1f05d71d850cda998681a58ac8f01a
5
5
  SHA512:
6
- metadata.gz: b0c1a0ad3b519d054af3874aaf3a9f7a2b89bc2b3c287f6b8a21eae5344ee3eb29f6699d63da2ad2489ad5e0b0c5708f3c931328fd432e98fe6ec175a68d6742
7
- data.tar.gz: '0099e0d3d525d033d8ea70187979df6849e67cbfe632cd1967154c9b6ba50212255ffb9daf2a5e4549538b256e627d9c384cfc139fe6e0e9137201839af93cec'
6
+ metadata.gz: dd8b8a316b2fd98445a3d7e387ed54218af99788c40aa0cf73b8bc149339bdc525b7e8cdb47da4cf211d642e65dfa591aabfb2e2ea49fe82650e58ad157f7099
7
+ data.tar.gz: 760f09adcce3a26ebb9093f019413e0b6ac14cc020f4cd8c4fbe4aff348bd75651b0c4170eabfd7b64445b47136181f56d9a0d0a38e9af6e60c399a16291b7a1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,151 @@
1
+ ### 2.0.23
2
+
3
+ 2023-04-16 10:33
4
+
5
+ #### IMPROVED
6
+
7
+ - Use Readline for entering info with `--paste`, allows for better editing experience
8
+ - Allow `--edit` with `--paste` to open the new snippet in your editor immediately
9
+
10
+ #### FIXED
11
+
12
+ - Code indentation with `--paste`
13
+
14
+ ### 2.0.22
15
+
16
+ 2023-04-16 09:33
17
+
18
+ #### IMPROVED
19
+
20
+ - Use Readline for entering info with `--paste`, allows for better editing experience
21
+
22
+ #### FIXED
23
+
24
+ - Code indentation with `--paste`
25
+
26
+ ### 2.0.21
27
+
28
+ 2023-04-16 09:04
29
+
30
+ #### IMPROVED
31
+
32
+ - Use leading and trailing hashes to make snippet titles more obvious when outputting All Snippets
33
+
34
+ ### 2.0.20
35
+
36
+ 2023-04-16 08:31
37
+
38
+ #### FIXED
39
+
40
+ - Fail to include skylighting themes in gem bundle
41
+ - Failure to recognize fenced code blocks with language specifiers containing hyphens
42
+
43
+ ### 2.0.19
44
+
45
+ 2023-04-16 08:05
46
+
47
+ #### FIXED
48
+
49
+ - A fenced code block following a line containing only 4+ spaces or tabs would get parsed as an indented code block
50
+ - Last fenced code block in a snippet might not be recognized
51
+
52
+ ### 2.0.18
53
+
54
+ 2023-04-16 06:57
55
+
56
+ #### FIXED
57
+
58
+ - If an invalid language (without a lexer) is supplied when using `--paste`, just use the input as the extension and tag
59
+
60
+ ### 2.0.17
61
+
62
+ 2023-04-16 06:31
63
+
64
+ #### NEW
65
+
66
+ - Languages specified in the opening fence of a code block are passed to the syntax highlighter (only affects Skylighting)
67
+
68
+ #### IMPROVED
69
+
70
+ - Add all available themes for Skylighting
71
+ - Allow a custom theme path to be provided for Skylighting by including a path in `highlight_theme` config
72
+ - Handle syntax highlighter errors, returning plain code if command fails
73
+
74
+ #### FIXED
75
+
76
+ - Disable syntax highlighting when command is being piped or redirected
77
+ - Don't syntax highlight clipboard code when using `--copy`
78
+
79
+ ### 2.0.16
80
+
81
+ 2023-04-15 22:15
82
+
83
+ #### FIXED
84
+
85
+ - Remove debugging output
86
+
87
+ ### 2.0.15
88
+
89
+ 2023-04-15 22:11
90
+
91
+ #### NEW
92
+
93
+ - Additional themes for skylighting: nord, monokai, solarized-light/dark
94
+
95
+ #### FIXED
96
+
97
+ - Bad path to highlighter themes for skylighting
98
+
99
+ ### 2.0.14
100
+
101
+ 2023-04-15 21:21
102
+
103
+ #### IMPROVED
104
+
105
+ - Better default themes for highlighters
106
+
107
+ #### FIXED
108
+
109
+ - Error with lexers_db when using higlighting
110
+
111
+ ### 2.0.13
112
+
113
+ 2023-04-15 19:57
114
+
115
+ #### NEW
116
+
117
+ - Option to include blockquotes (>) in output
118
+
119
+ ### 2.0.12
120
+
121
+ 2023-04-15 19:28
122
+
123
+ #### FIXED
124
+
125
+ - Lowered minimum ruby version to allow Ruby 2.6
126
+ - Failure to recognize snippet if title is on first line of file
127
+ - Errantly discarding first snippet in file with multiple snippets
128
+
129
+ ### 2.0.11
130
+
131
+ 2023-04-15 19:06
132
+
133
+ #### FIXED
134
+
135
+ - Overactive stripping of newlines within code blocks
136
+ - Syntax definition determination when adding new snippets
137
+
138
+ ### 2.0.10
139
+
140
+ 2023-04-15 16:28
141
+
142
+ #### FIXED
143
+
144
+ - Update dependencies for security
145
+ - Incorporate fixes from @robjwells addressing #3 and #4
146
+ - Incorporate fixes from @robjwells addressing #3 and #4
147
+ - Best menu CLI determination missing modules
148
+
1
149
  ### 2.0.9
2
150
 
3
151
  2023-04-15 15:44
@@ -34,6 +182,6 @@
34
182
 
35
183
  - Refactor script as modules and classes
36
184
 
37
- ## 2.0.2
185
+ ### 2.0.2
38
186
 
39
187
  Initial release as a gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snibbets (2.0.21)
4
+ snibbets (2.0.23)
5
+ mdless (~> 1.0, >= 1.0.32)
6
+ tty-reader (~> 0.9, >= 0.9.0)
5
7
  tty-which (~> 0.5, >= 0.5.0)
6
8
 
7
9
  GEM
@@ -15,6 +17,7 @@ GEM
15
17
  gem-release (2.2.2)
16
18
  json (2.6.3)
17
19
  language_server-protocol (3.17.0.3)
20
+ mdless (1.0.32)
18
21
  multi_json (1.15.0)
19
22
  parallel (1.22.1)
20
23
  parse_gemspec (1.0.0)
@@ -75,8 +78,15 @@ GEM
75
78
  terminal-table (3.0.2)
76
79
  unicode-display_width (>= 1.1.1, < 3)
77
80
  thor (1.2.1)
81
+ tty-cursor (0.7.1)
82
+ tty-reader (0.9.0)
83
+ tty-cursor (~> 0.7)
84
+ tty-screen (~> 0.8)
85
+ wisper (~> 2.0)
86
+ tty-screen (0.8.1)
78
87
  tty-which (0.5.0)
79
88
  unicode-display_width (2.4.2)
89
+ wisper (2.0.1)
80
90
  yard (0.9.34)
81
91
 
82
92
  PLATFORMS
data/README.md CHANGED
@@ -24,7 +24,7 @@ The name of the file should be the description of the snippet, at least in the c
24
24
 
25
25
  You can combine multiple snippets in a file, though. For example, I have a file called 'Ruby hash snippets.rb.md'. That file contains an array of useful snippets, and each one has a descriptive title in an h3 header above it. Those (ATX) headers are used to split the file, and when you search from the command line, you'll get a menu of all of the snippets in the selected file. (And if you have [fzf](https://github.com/junegunn/fzf) or [gum](https://github.com/charmbracelet/gum) installed, you can quickly filter through with fuzzy searching and find exactly what you need.)
26
26
 
27
- If a file contains multiple snippets, they should be separated by ATX-style headers (one or more `#`) describing the snippets. Additional descriptions can be included outside of the code block. For example:
27
+ If a file contains multiple snippets, they should be separated by ATX-style headers (one or more `#`) describing the snippets. Additional descriptions and notes can be included outside of the code block. Notes are not output on the console, only the code is displayed. If you want a note to be included in console output, make it a blockquote by preceding it with `>`.
28
28
 
29
29
  A file titled `unix find.bash.md`:
30
30
 
@@ -45,13 +45,13 @@ A file titled `unix find.bash.md`:
45
45
 
46
46
  find /dir/dir -type f -mtime +540 -mtime -720 -printf \"%p\",\"%s\",\"%AD\",|"%TD\"\\n > /dir/dir/output.csv
47
47
 
48
- You can include MultiMarkdown metadata in your snippets, either in a YAML block or just at the top of the file with raw key/value pairs. I mostly use this for adding tags, which are then synced to macOS tags when I save. It makes it easy to search for snippets in [nvUltra](https://nvultra.com/), and also allows you to do searches like `snibbets tag:javascript url parser` in Snibbets.
48
+ You can include MultiMarkdown metadata in your snippets, either in a YAML block or just at the top of the file with raw key/value pairs. I mostly use this for adding tags, which are then synced to macOS tags when I save. It makes it easy to search for snippets in [nvUltra](https://nvultra.com/), and also allows you to do searches like `snibbets tag:javascript url parser` with Snibbets.
49
49
 
50
50
  ## CLI
51
51
 
52
52
  ### Dependencies
53
53
 
54
- Snibbets requires Ruby 3.0+. On recent versions of macOS, this is not included by default. You can install it via the Command Line Tools from Apple. On macOS and most other systems, you can use something like [Homebrew], [rbenv], [rvm], or [asdf] to install Ruby 3.
54
+ Snibbets requires Ruby 3.0+. On recent versions of macOS, this is not included by default. You can install it via the Command Line Tools from Apple. On macOS and most other systems, you can also use something like [Homebrew], [rbenv], [rvm], or [asdf] to install Ruby 3.
55
55
 
56
56
  If available, menus are generated by [fzf] or [gum]. If neither are available, a basic Readline menu system will be displayed, so neither are required, just nice to have as they provide fuzzy filtering, scrolling, and type-ahead completion.
57
57
 
@@ -155,7 +155,7 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
155
155
  ### Usage
156
156
 
157
157
  ```
158
- Snibbets v2.0.21
158
+ Snibbets v2.0.23
159
159
 
160
160
  Usage: snibbets [options] query
161
161
  -a, --all If a file contains multiple snippets, output all of them (no menu)
@@ -172,6 +172,7 @@ Usage: snibbets [options] query
172
172
  --save Save the current command line options to the YAML configuration
173
173
  -h, --help Display this screen
174
174
  -v, --version Display version information
175
+ --changes Display the changelog (release notes)
175
176
  ```
176
177
 
177
178
  If your Snippets folder is set in the config, simply running `snibbets [search query]` will perform the search and output the code blocks, presenting a menu if more than one match is found or the target file contains more than one snippet. Selected contents are output raw to STDOUT.
data/bin/snibbets CHANGED
@@ -8,6 +8,21 @@ module Snibbets
8
8
  class << self
9
9
  attr_reader :query
10
10
 
11
+ def display_changelog
12
+ changelog = File.expand_path(File.join(__dir__, '..', 'CHANGELOG.md'))
13
+ pagers = [
14
+ 'mdless',
15
+ 'mdcat -p',
16
+ 'bat',
17
+ ENV['PAGER'],
18
+ 'less -FXr',
19
+ ENV['GIT_PAGER'],
20
+ 'more -r'
21
+ ]
22
+ pager = pagers.find { |cmd| TTY::Which.exist?(cmd.split.first) }
23
+ system %(#{TTY::Which.which(pager)} "#{changelog}")
24
+ end
25
+
11
26
  def run
12
27
  options = Snibbets.options
13
28
  arguments = Snibbets.arguments
@@ -81,6 +96,11 @@ module Snibbets
81
96
  puts "Snibbets v#{VERSION}"
82
97
  Process.exit 0
83
98
  end
99
+
100
+ opts.on('--changes', 'Display the changelog (release notes)') do
101
+ display_changelog
102
+ Process.exit 0
103
+ end
84
104
  end
85
105
 
86
106
  optparse.parse!
data/buildnotes.md CHANGED
@@ -8,7 +8,11 @@ project: snibbets
8
8
 
9
9
  A plain text snippet manager
10
10
 
11
- ## Test
11
+ ## Develop
12
+
13
+ @run(subl .)
14
+
15
+ ## Dummy
12
16
 
13
17
  @run(bundle exec bin/snibbets $@)
14
18
 
@@ -35,7 +39,3 @@ git push
35
39
  @after
36
40
  Don't forget to publish the website!
37
41
  @end
38
-
39
- ## Plans
40
-
41
-
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snibbets
4
- VERSION = '2.0.21'
4
+ VERSION = '2.0.23'
5
5
  end
data/lib/snibbets.rb CHANGED
@@ -8,6 +8,7 @@ require 'shellwords'
8
8
  require 'yaml'
9
9
  require 'fileutils'
10
10
  require 'tty-which'
11
+ require 'tty-reader'
11
12
  require 'open3'
12
13
  require_relative 'snibbets/version'
13
14
  require_relative 'snibbets/config'
@@ -143,36 +144,43 @@ module Snibbets
143
144
  end
144
145
 
145
146
  def new_snippet_from_clipboard
147
+ return false unless $stdin.isatty
148
+
146
149
  trap('SIGINT') do
147
150
  Howzit.console.info "\nCancelled"
148
151
  exit!
149
152
  end
150
153
 
151
154
  pb = OS.paste.outdent
155
+ reader = TTY::Reader.new
152
156
 
153
- printf 'What does this snippet do? '
154
- input = $stdin.gets.chomp
157
+ # printf 'What does this snippet do? '
158
+ input = reader.read_line('What does this snippet do? ').strip
159
+ # input = $stdin.gets.chomp
155
160
  title = input unless input.empty?
156
161
 
157
- printf 'What language(s) does it use (separate with spaces, full names or file extensions will work)? '
158
- input = $stdin.gets.chomp
162
+ # printf 'What language(s) does it use (separate with spaces, full names or file extensions will work)? '
163
+ input = reader.read_line('What language(s) does it use (separate with spaces, full names or file extensions will work)? ').strip
164
+ # input = $stdin.gets.chomp
159
165
  langs = input.split(/ +/).map(&:strip) unless input.empty?
160
166
  exts = langs.map { |lang| Lexers.lang_to_ext(lang) }.delete_if(&:nil?)
161
167
  tags = langs.map { |lang| Lexers.ext_to_lang(lang) }.concat(langs).delete_if(&:nil?).sort.uniq
162
168
 
163
169
  exts = langs if exts.empty?
164
170
 
165
- filename = "#{title}.#{exts.join('.')}.#{Snibbets.options[:extension]}"
166
-
167
- File.open(File.join(File.expand_path(Snibbets.options[:source]), filename), 'w') do |f|
171
+ filename = "#{title}#{exts.map { |x| ".#{x}"}.join('')}.#{Snibbets.options[:extension]}"
172
+ filepath = File.join(File.expand_path(Snibbets.options[:source]), filename)
173
+ File.open(filepath, 'w') do |f|
168
174
  f.puts "tags: #{tags.join(', ')}
169
175
 
170
- ```
171
- #{pb}
172
- ```"
176
+ ```
177
+ #{pb}
178
+ ```"
173
179
  end
174
180
 
175
181
  puts "New snippet written to #{filename}."
182
+
183
+ open_snippet_in_editor(filepath) if Snibbets.arguments[:edit_snippet]
176
184
  end
177
185
 
178
186
  def handle_launchbar(results)
data/snibbets.gemspec CHANGED
@@ -43,4 +43,6 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "simplecov-console", "~> 0.9"
44
44
  spec.add_development_dependency "standard", "~> 1.3"
45
45
  spec.add_runtime_dependency 'tty-which', '~> 0.5', '>= 0.5.0'
46
+ spec.add_runtime_dependency('tty-reader', '~> 0.9', '>= 0.9.0')
47
+ spec.add_runtime_dependency('mdless', '~> 1.0', '>= 1.0.32')
46
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snibbets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.21
4
+ version: 2.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -190,6 +190,46 @@ dependencies:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: 0.5.0
193
+ - !ruby/object:Gem::Dependency
194
+ name: tty-reader
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '0.9'
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 0.9.0
203
+ type: :runtime
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: '0.9'
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: 0.9.0
213
+ - !ruby/object:Gem::Dependency
214
+ name: mdless
215
+ requirement: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: '1.0'
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 1.0.32
223
+ type: :runtime
224
+ prerelease: false
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '1.0'
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: 1.0.32
193
233
  description: A plain text code snippet manager
194
234
  email: me@brettterpstra.com
195
235
  executables:
@@ -199,7 +239,6 @@ extra_rdoc_files:
199
239
  - README.md
200
240
  files:
201
241
  - CHANGELOG.md
202
- - CHANGELOG.md.orig
203
242
  - Gemfile
204
243
  - Gemfile.lock
205
244
  - Gemfile.lock.orig
data/CHANGELOG.md.orig DELETED
@@ -1,168 +0,0 @@
1
- ### 2.0.21
2
-
3
- 2023-04-16 09:04
4
-
5
- #### IMPROVED
6
-
7
- - Use leading and trailing hashes to make snippet titles more obvious when outputting All Snippets
8
-
9
- ### 2.0.20
10
-
11
- 2023-04-16 08:31
12
-
13
- #### FIXED
14
-
15
- - Fail to include skylighting themes in gem bundle
16
- - Failure to recognize fenced code blocks with language specifiers containing hyphens
17
-
18
- ### 2.0.19
19
-
20
- 2023-04-16 08:05
21
-
22
- #### FIXED
23
-
24
- - A fenced code block following a line containing only 4+ spaces or tabs would get parsed as an indented code block
25
- - Last fenced code block in a snippet might not be recognized
26
-
27
- ### 2.0.18
28
-
29
- 2023-04-16 06:57
30
-
31
- #### FIXED
32
-
33
- - If an invalid language (without a lexer) is supplied when using `--paste`, just use the input as the extension and tag
34
-
35
- ### 2.0.17
36
-
37
- 2023-04-16 06:31
38
-
39
- #### NEW
40
-
41
- - Languages specified in the opening fence of a code block are passed to the syntax highlighter (only affects Skylighting)
42
-
43
- #### IMPROVED
44
-
45
- - Add all available themes for Skylighting
46
- - Allow a custom theme path to be provided for Skylighting by including a path in `highlight_theme` config
47
- - Handle syntax highlighter errors, returning plain code if command fails
48
-
49
- #### FIXED
50
-
51
- - Disable syntax highlighting when command is being piped or redirected
52
- - Don't syntax highlight clipboard code when using `--copy`
53
-
54
- ### 2.0.16
55
-
56
- 2023-04-15 22:15
57
-
58
- #### FIXED
59
-
60
- - Remove debugging output
61
-
62
- ### 2.0.15
63
-
64
- 2023-04-15 22:11
65
-
66
- #### NEW
67
-
68
- - Additional themes for skylighting: nord, monokai, solarized-light/dark
69
-
70
- #### FIXED
71
-
72
- - Bad path to highlighter themes for skylighting
73
-
74
- ### 2.0.14
75
-
76
- 2023-04-15 21:21
77
-
78
- #### IMPROVED
79
-
80
- - Better default themes for highlighters
81
-
82
- #### FIXED
83
-
84
- - Error with lexers_db when using higlighting
85
-
86
- ### 2.0.13
87
-
88
- 2023-04-15 19:57
89
-
90
- #### NEW
91
-
92
- - Option to include blockquotes (>) in output
93
-
94
- ### 2.0.12
95
-
96
- 2023-04-15 19:28
97
-
98
- #### FIXED
99
-
100
- - Lowered minimum ruby version to allow Ruby 2.6
101
- - Failure to recognize snippet if title is on first line of file
102
- - Errantly discarding first snippet in file with multiple snippets
103
-
104
- ### 2.0.11
105
-
106
- 2023-04-15 19:06
107
-
108
- #### FIXED
109
-
110
- - Overactive stripping of newlines within code blocks
111
- - Syntax definition determination when adding new snippets
112
-
113
- ### 2.0.10
114
-
115
- 2023-04-15 16:28
116
-
117
- #### FIXED
118
-
119
- - Update dependencies for security
120
- - Incorporate fixes from @robjwells addressing #3 and #4
121
- - Incorporate fixes from @robjwells addressing #3 and #4
122
- - Best menu CLI determination missing modules
123
-
124
- <<<<<<< HEAD
125
- ### 2.0.7
126
-
127
- 2023-04-15 12:02
128
- =======
129
- ### 2.0.9
130
-
131
- 2023-04-15 15:44
132
-
133
- #### IMPROVED
134
-
135
- - Allow setting `menus` config key to force Snibbets to use fzf, gum, or console menus
136
- - Allow setting `menus` config key to force Snibbets to use fzf, gum, or console menus
137
-
138
- #### FIXED
139
-
140
- - If a header section contains no code blocks, don't display it in menu
141
- - Remove leading and trailing newlines without affecting indentation
142
-
143
- ### 2.0.8
144
-
145
- 2023-04-15 15:41
146
-
147
- #### IMPROVED
148
-
149
- - Allow setting `menus` config key to force Snibbets to use fzf, gum, or console menus
150
- - Allow setting `menus` config key to force Snibbets to use fzf, gum, or console menus
151
-
152
- #### FIXED
153
-
154
- - If a header section contains no code blocks, don't display it in menu
155
- - Remove leading and trailing newlines without affecting indentation
156
- >>>>>>> release/2.0.9
157
-
158
- ### 2.0.6
159
-
160
- 2023-04-15 11:55
161
-
162
- #### IMPROVED
163
-
164
- - Refactor script as modules and classes
165
-
166
- ## 2.0.2
167
-
168
- Initial release as a gem