howzit 2.0.19 → 2.0.22

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: 7c08d6ceea211cc4e603a59c5e2f1ac7c2db806d55a8eaa1f260e1f0994bdf45
4
- data.tar.gz: c5b6c284c725a8f1edabc07723a18d0e9d9c56204be0b7fb50e0d3bb1b5efccf
3
+ metadata.gz: 7e00517a83b13075c8af7884b3a5afd683f62008f6ccc8b50015044e7625a6b7
4
+ data.tar.gz: 1918ceb4965f7a5fe127581c1dd602dfa387d8e310654f5ac7ca643ab5dd4c8d
5
5
  SHA512:
6
- metadata.gz: 8c456e2c7f820777d6e07a26fcc677bfa8ac09a12bd409e870c37dbaa431f186ac551575b6eead585d446a02b533b5c729eba4dfac40b2caa876ff9f63400c9b
7
- data.tar.gz: 03717f2b209cf812b31e5da66ab57000e7e54cd52efa08b8bc7e4c2840e30581509af401e76e8ccef9e5cd0b232d04601eb6d5723b49cc1e6ae3bb7e760bff29
6
+ metadata.gz: 549952e3e175d9fcd5df9d85400a8abc3279ff76862e172029e974920ba85aa8ef1dfb84fcdbaff94a260a5630f49c462cd58d5a97f359735978c074b9742c2d
7
+ data.tar.gz: acb315d65c7cb1f9cf3e1ee6ef9044a1f7584b23f4bc1a7d58b39acda4851a62e58d55fe53fa227807c84f01093f3f07c6ad18070ceffda92ba05fe72f137573
data/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ ### 2.0.22
2
+
3
+ 2022-08-08 13:49
4
+
5
+ #### IMPROVED
6
+
7
+ - Paginate output of --templates
8
+
9
+ #### FIXED
10
+
11
+ - --templates attempting to create new build note
12
+ - Fix handling of paths when the same as note_file
13
+
14
+ ### 2.0.21
15
+
16
+ 2022-08-08 13:16
17
+
18
+ #### IMPROVED
19
+
20
+ - Use os-agnostic copy function for --hook
21
+ - Rename link title for --hook
22
+
23
+ ### 2.0.20
24
+
25
+ 2022-08-08 11:38
26
+
27
+ #### NEW
28
+
29
+ - --hook command for macOS to copy a link to the build note to clipboard
30
+
31
+ #### FIXED
32
+
33
+ - Error on --edit-config
34
+ - Fzf preview empty
35
+
1
36
  ### 2.0.19
2
37
 
3
38
  2022-08-08 06:18
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Howzit
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/howzit.svg)](https://rubygems.org/gems/howzit)
4
- [![Travis](https://img.shields.io/travis/makenew/ruby-gem.svg)](https://travis-ci.org/makenew/ruby-gem)
4
+ [![Travis](https://api.travis-ci.com/ttscoff/howzit.svg?branch=main)](https://travis-ci.org/makenew/ruby-gem)
5
5
  [![GitHub license](https://img.shields.io/github/license/ttscoff/howzit.svg)](./LICENSE.txt)
6
6
 
7
7
  A command-line reference tool for tracking project build systems
data/bin/howzit CHANGED
@@ -64,25 +64,27 @@ OptionParser.new do |opts|
64
64
  end
65
65
 
66
66
  opts.on('--templates', 'List available templates') do
67
+ out = []
67
68
  Dir.chdir(Howzit.config.template_folder)
68
69
  Dir.glob('*.md').each do |file|
69
70
  template = File.basename(file, '.md')
70
- puts Howzit::Color.template("{Mk}template:{Yk}#{template}{x}")
71
- puts Howzit::Color.template('{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}')
71
+ out.push(Howzit::Color.template("{Mk}template:{Yk}#{template}{x}"))
72
+ out.push(Howzit::Color.template('{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}'))
72
73
  metadata = file.extract_metadata
73
- topics = Howzit.buildnote.read_file(file)
74
+ topics = Howzit::BuildNote.new(file: file).topics
74
75
  topics.each do |topic|
75
- puts Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}")
76
+ out.push(Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}"))
76
77
  end
77
78
  unless metadata.empty?
78
79
  meta = []
79
80
  meta << metadata['required'].split(/\s*,\s*/).map { |m| "*{bw}#{m}{xw}" } if metadata.key?('required')
80
81
  meta << metadata['optional'].split(/\s*,\s*/).map(&:to_s) if metadata.key?('optional')
81
- puts Howzit::Color.template('{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}')
82
- puts Howzit::Color.template(" {bk}│ {xw}#{meta.join(', ')}{x}")
82
+ out.push(Howzit::Color.template('{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}'))
83
+ out.push(Howzit::Color.template(" {bk}│ {xw}#{meta.join(', ')}{x}"))
83
84
  end
84
- puts Howzit::Color.template(' {bk}└───────────────────────────────────────────┘{x}')
85
+ out.push(Howzit::Color.template(' {bk}└───────────────────────────────────────────┘{x}'))
85
86
  end
87
+ Howzit::Util.page out.join("\n")
86
88
  Process.exit 0
87
89
  end
88
90
 
@@ -131,13 +133,15 @@ OptionParser.new do |opts|
131
133
  Process.exit 0
132
134
  end
133
135
 
134
- desc = %(Edit buildnotes file in current working directory using editor (#{File.basename(Howzit.options[:config_editor])}))
136
+ editor = File.basename(Howzit.options[:editor])
137
+ desc = %(Edit buildnotes file in current working directory using editor (#{editor}))
135
138
  opts.on('-e', '--edit', desc) do
136
139
  Howzit.buildnote.edit
137
140
  Process.exit 0
138
141
  end
139
142
 
140
- opts.on('--edit-config', "Edit configuration file using editor (#{File.basename(Howzit.options[:editor])})") do
143
+ config_editor = File.basename(Howzit.options[:config_editor])
144
+ opts.on('--edit-config', "Edit configuration file using editor (#{config_editor})") do
141
145
  Howzit.config.editor
142
146
  Process.exit 0
143
147
  end
@@ -151,6 +155,11 @@ OptionParser.new do |opts|
151
155
  Howzit.options[:grep] = pat
152
156
  end
153
157
 
158
+ opts.on('--hook', 'Copy a link to the build note file, ready for pasting into Hook.app or other notes') do
159
+ Howzit.buildnote.hook
160
+ Process.exit 0
161
+ end
162
+
154
163
  opts.on('-r', '--run', 'Execute @run, @open, and/or @copy commands for given topic') do
155
164
  Howzit.options[:run] = true
156
165
  end
@@ -12,6 +12,7 @@ complete -c howzit -l templates -d "List available templates"
12
12
  complete -c howzit -l title-only -d "Output title only"
13
13
  complete -c howzit -s c -l create -d "Create a skeleton build note in the current working directory"
14
14
  complete -c howzit -f -l config-get -d "Display the configuration settings or setting for a specific key"
15
+ complete -c howzit -f -l hook -d "Copy a link to the build notes file (macOS)"
15
16
  complete -c howzit -f -l config-set -d "Set a config value (must be a valid key)"
16
17
  complete -c howzit -l edit-config -d "Edit configuration file using editor (subl)"
17
18
  complete -c howzit -s e -l edit -d "Edit buildnotes file in current working directory using editor (subl)"
@@ -13,11 +13,13 @@ module Howzit
13
13
  ## @param file [String] The path to the build note file
14
14
  ##
15
15
  def initialize(file: nil)
16
+ file ||= note_file
17
+
16
18
  @topics = []
17
- create_note(prompt: true) if note_file.nil?
19
+ create_note(prompt: true) if file.nil?
18
20
 
19
- content = Util.read_file(note_file)
20
- raise "{br}No content found in build note (#{note_file}){x}".c if content.nil? || content.empty?
21
+ content = Util.read_file(file)
22
+ raise "{br}No content found in build note (#{file}){x}".c if content.nil? || content.empty?
21
23
 
22
24
  @metadata = content.split(/^#/)[0].strip.get_metadata
23
25
 
@@ -72,6 +74,17 @@ module Howzit
72
74
  end
73
75
  end
74
76
 
77
+ ##
78
+ ## Copy a link to the main build note file to clipboard (macOS only)
79
+ ##
80
+ def hook
81
+ title = Util.read_file(note_file).note_title(note_file, 20)
82
+ title = "#{title} project notes"
83
+ url = "[#{title}](file://#{note_file})"
84
+ Util.os_copy(url)
85
+ Howzit.console.info('Link copied to clipboard.')
86
+ end
87
+
75
88
  ##
76
89
  ## Call grep on all topics, filtering out those that don't match
77
90
  ##
@@ -585,7 +598,7 @@ module Howzit
585
598
  lines = sect.split(/\n/)
586
599
  title = lines.slice!(0).strip
587
600
  prefix = ''
588
- if path
601
+ if path && path != note_file
589
602
  if path =~ /#{Howzit.config.template_folder}/
590
603
  short_path = File.basename(path, '.md')
591
604
  else
data/lib/howzit/config.rb CHANGED
@@ -74,7 +74,7 @@ module Howzit
74
74
  ## Initiate the editor for the config
75
75
  ##
76
76
  def editor
77
- edit_config(DEFAULTS)
77
+ edit_config
78
78
  end
79
79
 
80
80
  private
data/lib/howzit/prompt.rb CHANGED
@@ -100,7 +100,7 @@ module Howzit
100
100
  "--height=#{height}",
101
101
  '--header="Use tab to mark multiple selections, enter to display/run"',
102
102
  '--prompt="Select a section > "',
103
- '--preview="howzit {}"'
103
+ %(--preview="howzit --no-pager --header-format block --no-color --default --multiple first {}")
104
104
  ]
105
105
  res = `echo #{Shellwords.escape(matches.join("\n"))} | fzf #{settings.join(' ')}`.strip
106
106
  if res.nil? || res.empty?
data/lib/howzit/task.rb CHANGED
@@ -94,62 +94,7 @@ module Howzit
94
94
  def run_copy
95
95
  title = Howzit.options[:show_all_code] ? @action : @title
96
96
  Howzit.console.info("{bg}Copied {bw}#{title}{bg} to clipboard{x}".c)
97
- os_copy(@action)
98
- end
99
-
100
- ##
101
- ## Platform-agnostic copy-to-clipboard
102
- ##
103
- ## @param string [String] The string to copy
104
- ##
105
- def os_copy(string)
106
- os = RbConfig::CONFIG['target_os']
107
- out = "{bg}Copying {bw}#{string}".c
108
- case os
109
- when /darwin.*/i
110
- Howzit.console.debug("#{out} (macOS){x}".c)
111
- `echo #{Shellwords.escape(string)}'\\c'|pbcopy`
112
- when /mingw|mswin/i
113
- Howzit.console.debug("#{out} (Windows){x}".c)
114
- `echo #{Shellwords.escape(string)} | clip`
115
- else
116
- if 'xsel'.available?
117
- Howzit.console.debug("#{out} (Linux, xsel){x}".c)
118
- `echo #{Shellwords.escape(string)}'\\c'|xsel -i`
119
- elsif 'xclip'.available?
120
- Howzit.console.debug("#{out} (Linux, xclip){x}".c)
121
- `echo #{Shellwords.escape(string)}'\\c'|xclip -i`
122
- else
123
- Howzit.console.debug(out)
124
- Howzit.console.warn('Unable to determine executable for clipboard.')
125
- end
126
- end
127
- end
128
-
129
- ##
130
- ## Platform-agnostic open command
131
- ##
132
- ## @param command [String] The command
133
- ##
134
- def os_open(command)
135
- os = RbConfig::CONFIG['target_os']
136
- out = "{bg}Opening {bw}#{command}".c
137
- case os
138
- when /darwin.*/i
139
- Howzit.console.debug "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
140
- `open #{Shellwords.escape(command)}`
141
- when /mingw|mswin/i
142
- Howzit.console.debug "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
143
- `start #{Shellwords.escape(command)}`
144
- else
145
- if 'xdg-open'.available?
146
- Howzit.console.debug "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
147
- `xdg-open #{Shellwords.escape(command)}`
148
- else
149
- Howzit.console.debug out if Howzit.options[:log_level] < 2
150
- Howzit.console.debug 'Unable to determine executable for `open`.'
151
- end
152
- end
97
+ Util.os_copy(@action)
153
98
  end
154
99
 
155
100
  ##
@@ -169,7 +114,7 @@ module Howzit
169
114
  when :copy
170
115
  run_copy
171
116
  when :open
172
- os_open(@action)
117
+ Util.os_open(@action)
173
118
  end
174
119
  end
175
120
 
data/lib/howzit/util.rb CHANGED
@@ -179,6 +179,61 @@ module Howzit
179
179
  puts output
180
180
  end
181
181
  end
182
+
183
+ ##
184
+ ## Platform-agnostic copy-to-clipboard
185
+ ##
186
+ ## @param string [String] The string to copy
187
+ ##
188
+ def os_copy(string)
189
+ os = RbConfig::CONFIG['target_os']
190
+ out = "{bg}Copying {bw}#{string}".c
191
+ case os
192
+ when /darwin.*/i
193
+ Howzit.console.debug("#{out} (macOS){x}".c)
194
+ `echo #{Shellwords.escape(string)}'\\c'|pbcopy`
195
+ when /mingw|mswin/i
196
+ Howzit.console.debug("#{out} (Windows){x}".c)
197
+ `echo #{Shellwords.escape(string)} | clip`
198
+ else
199
+ if 'xsel'.available?
200
+ Howzit.console.debug("#{out} (Linux, xsel){x}".c)
201
+ `echo #{Shellwords.escape(string)}'\\c'|xsel -i`
202
+ elsif 'xclip'.available?
203
+ Howzit.console.debug("#{out} (Linux, xclip){x}".c)
204
+ `echo #{Shellwords.escape(string)}'\\c'|xclip -i`
205
+ else
206
+ Howzit.console.debug(out)
207
+ Howzit.console.warn('Unable to determine executable for clipboard.')
208
+ end
209
+ end
210
+ end
211
+
212
+ ##
213
+ ## Platform-agnostic open command
214
+ ##
215
+ ## @param command [String] The command
216
+ ##
217
+ def os_open(command)
218
+ os = RbConfig::CONFIG['target_os']
219
+ out = "{bg}Opening {bw}#{command}".c
220
+ case os
221
+ when /darwin.*/i
222
+ Howzit.console.debug "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
223
+ `open #{Shellwords.escape(command)}`
224
+ when /mingw|mswin/i
225
+ Howzit.console.debug "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
226
+ `start #{Shellwords.escape(command)}`
227
+ else
228
+ if 'xdg-open'.available?
229
+ Howzit.console.debug "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
230
+ `xdg-open #{Shellwords.escape(command)}`
231
+ else
232
+ Howzit.console.debug out if Howzit.options[:log_level] < 2
233
+ Howzit.console.debug 'Unable to determine executable for `open`.'
234
+ end
235
+ end
236
+ end
182
237
  end
183
238
  end
184
239
  end
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.0.19'
6
+ VERSION = '2.0.22'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: howzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.19
4
+ version: 2.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra