howzit 1.2.13 → 1.2.16

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: 36a27d1566deff8857d39035c0e40f696a29d78b7ae24274a73ceacc54541321
4
- data.tar.gz: 7b13d6644bf397e10f629689b159102a33dd5aa2c3610f368819de3dc8736007
3
+ metadata.gz: 14bc9569ad9313ee45f42b23fb1181ad3c70c4c7d7c69d436feff9804035c3ac
4
+ data.tar.gz: e40a8f4ca0e99a8e68c6df996d24bcd121a1d69dde2780f3836237303cf85e2c
5
5
  SHA512:
6
- metadata.gz: 9da1ea212df950e75a34006a44b0ade09c02fd4fe7c02ea0fddfffcf2936e6ca5db0d7f0c9e6cc44aac3d65eb4544aa9d4c03c156487f9311f39f08ee12199d4
7
- data.tar.gz: 99f9be58ff9184a2f96e7db6fed83e3fc19f0945e31c9d58daa32db022b175a8c99a329a9c023528af52100f46583ac892091eb04ed5d9e9e791087fe8f8c82d
6
+ metadata.gz: bfa974d861fe4d225239d8b4ed496a46feeba3048b7b1eba4ec61bc5fdc5ad33e46cd1dab97dcf4553b64b916bf59cb28a8d1f3605cff6a7d222752266e0e644
7
+ data.tar.gz: 02c3c096d1841122c1e027274912b233e167a073c711945cad72186741e759f1c007d421a5accee7c86c0474742a033789e076a53d4858852c673317ccd0b56b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
1
+ ### 1.2.16
2
+
3
+ 2022-08-03 11:41
4
+
5
+ #### IMPROVED
6
+
7
+ - Complete code refactoring
8
+
9
+ #### FIXED
10
+
11
+ - Multiple includes of upstream files when templates are specified
12
+
13
+ ### 1.2.15
14
+
15
+ 2022-08-02 11:59
16
+
17
+ #### NEW
18
+
19
+ - Option to set :header_format: to block for alternate topic title appearance
20
+
21
+ #### FIXED
22
+
23
+ - Missing spacing around topic titles when displaying multiple topics
24
+
25
+ ### 1.2.14
26
+
27
+ 2022-08-02 11:01
28
+
29
+ #### NEW
30
+
31
+ - Config option and flag to determine how to handle multiple results (first, best, all, choose)
32
+ - --config-get and --config-set flags for working with config options
33
+
34
+ #### IMPROVED
35
+
36
+ - Allow multiple selections when using fzf
37
+ - Clean up newlines in output
38
+
1
39
  ### 1.2.13
2
40
 
3
41
  2022-08-01 20:50
data/README.md CHANGED
@@ -24,11 +24,10 @@ Howzit is a tool that allows you to keep Markdown-formatted notes about a projec
24
24
 
25
25
  ## Getting Started
26
26
 
27
- Howzit is a simple, self-contained script (at least until I get stupid and make a gem out of it).
28
-
29
27
  ### Prerequisites
30
28
 
31
29
  - Ruby 2.4+ (It probably works on older Rubys, but is untested prior to 2.4.1.)
30
+ - Optional: if [`fzf`](https://github.com/junegunn/fzf) is available, it will be used for handling multiple choice selections
32
31
  - Optional: if [`bat`](https://github.com/sharkdp/bat) is available it will page with that
33
32
  - Optional: [`mdless`](https://github.com/ttscoff/mdless) or [`mdcat`](https://github.com/lunaryorn/mdcat) for formatting output
34
33
 
@@ -200,6 +199,10 @@ Include a topic name to see just that topic, or no argument to display all.
200
199
 
201
200
  howzit build
202
201
 
202
+ You can combine multiple topic searches by separating with a comma. When multiple results are returned, the `:multiple_results:` configuration determines how they're handled.
203
+
204
+ howzit build,deploy
205
+
203
206
  Use `-l` to list all topics.
204
207
 
205
208
  howzit -l
@@ -216,12 +219,15 @@ Other options:
216
219
 
217
220
  Options:
218
221
  -c, --create Create a skeleton build note in the current working directory
219
- -e, --edit Edit buildnotes file in current working directory using editor.sh
222
+ -e, --edit Edit buildnotes file in current working directory
223
+ using $EDITOR
220
224
  --grep PATTERN Display sections matching a search pattern
221
225
  -L, --list-completions List topics for completion
222
226
  -l, --list List available topics
223
227
  -m, --matching TYPE Topics matching type
224
228
  (partial, exact, fuzzy, beginswith)
229
+ --multiple TYPE Multiple result handling
230
+ (first, all, choose)
225
231
  -R, --list-runnable List topics containing @ directives (verbose)
226
232
  -r, --run Execute @run, @open, and/or @copy commands for given topic
227
233
  -s, --select Select topic from menu
@@ -229,10 +235,10 @@ Other options:
229
235
  -t, --title Output title with build notes
230
236
  -q, --quiet Silence info message
231
237
  --verbose Show all messages
232
- -u, --upstream Traverse up parent directories for additional build notes
238
+ -u, --[no-]upstream Traverse up parent directories for additional build notes
233
239
  --show-code Display the content of fenced run blocks
234
240
  -w, --wrap COLUMNS Wrap to specified width (default 80, 0 to disable)
235
- --edit-config Edit configuration file using editor.sh
241
+ --edit-config Edit configuration file using default $EDITOR
236
242
  --title-only Output title only
237
243
  --templates List available templates
238
244
  --[no-]color Colorize output (default on)
@@ -240,6 +246,7 @@ Other options:
240
246
  --[no-]pager Paginate output (default on)
241
247
  -h, --help Display this screen
242
248
  -v, --version Display version number
249
+ --default Answer all prompts with default response
243
250
 
244
251
 
245
252
  ## Configuration
@@ -257,6 +264,8 @@ Some of the command line options can be set as defaults. The first time you run
257
264
  :matching: partial
258
265
  :include_upstream: false
259
266
  :log_level: 1
267
+ :multiple_matches: choose
268
+ :header_format: border
260
269
 
261
270
  If `:color:` is false, output will not be colored, and markdown highlighting will be bypassed.
262
271
 
@@ -272,6 +281,10 @@ If `:include_upstream:` is true, build note files in parent directories will be
272
281
 
273
282
  Set `:log_level:` to 0 for debug messages, or 3 to suppress superfluous info messages.
274
283
 
284
+ `:multiple_matches:` determines how howzit will handle cases where a search results in multiple matches. It can be set to "first" (first match in notes), "best" (shortest topic match), "all" (display all results), or "choose" (displays a menu of results). Default is "choose." When grepping for results, only "all" or "choose" are valid, if the default is something else, "choose" will be used. Can be overridden with the `--multiple TYPE` flag.
285
+
286
+ `:header_format:` changes the way topic titles are displayed. Setting it to "border" will add a horizontal rule and brackets around the title. Setting it to "block" will mark topic titles with a unicode block instead.
287
+
275
288
  ### Matching
276
289
 
277
290
  All matching is case insensitive. This setting can be overridden by the `--matching TYPE` flag on the command line.
data/bin/howzit CHANGED
@@ -4,5 +4,196 @@
4
4
  $LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
5
5
  require 'howzit'
6
6
 
7
- how = Howzit::BuildNotes.new(ARGV)
8
- how.process
7
+ Howzit::Color.coloring = $stdout.isatty
8
+
9
+ parts = Shellwords.shelljoin(ARGV).split(/ -- /)
10
+ args = parts[0] ? Shellwords.shellsplit(parts[0]) : []
11
+ Howzit.arguments = parts[1] ? Shellwords.shellsplit(parts[1]) : []
12
+
13
+ OptionParser.new do |opts|
14
+ opts.banner = "Usage: #{__FILE__} [OPTIONS] [TOPIC]"
15
+ opts.separator ''
16
+ opts.separator 'Show build notes for the current project (buildnotes.md).
17
+ Include a topic name to see just that topic, or no argument to display all.'
18
+ opts.separator ''
19
+ opts.separator 'Options:'
20
+
21
+ opts.on('-c', '--create', 'Create a skeleton build note in the current working directory') do
22
+ Howzit.buildnote.create_note
23
+ Process.exit 0
24
+ end
25
+
26
+ opts.on('-e', '--edit', "Edit buildnotes file in current working directory
27
+ using $EDITOR") do
28
+ Howzit.buildnote.edit
29
+ Process.exit 0
30
+ end
31
+
32
+ opts.on('--grep PATTERN', 'Display sections matching a search pattern') do |pat|
33
+ Howzit.options[:grep] = pat
34
+ end
35
+
36
+ opts.on('-L', '--list-completions', 'List topics for completion') do
37
+ Howzit.options[:list_topics] = true
38
+ Howzit.options[:list_topic_titles] = true
39
+ end
40
+
41
+ opts.on('-l', '--list', 'List available topics') do
42
+ Howzit.options[:list_topics] = true
43
+ end
44
+
45
+ opts.on('-m', '--matching TYPE', MATCHING_OPTIONS,
46
+ 'Topics matching type', "(#{MATCHING_OPTIONS.join(', ')})") do |c|
47
+ Howzit.options[:matching] = c
48
+ end
49
+
50
+ opts.on('--multiple TYPE', MULTIPLE_OPTIONS,
51
+ 'Multiple result handling', "(#{MULTIPLE_OPTIONS.join(', ')}, default choose)") do |c|
52
+ Howzit.options[:multiple_matches] = c.to_sym
53
+ end
54
+
55
+ opts.on('-R', '--list-runnable', 'List topics containing @ directives (verbose)') do
56
+ Howzit.options[:list_runnable] = true
57
+ end
58
+
59
+ opts.on('-r', '--run', 'Execute @run, @open, and/or @copy commands for given topic') do
60
+ Howzit.options[:run] = true
61
+ end
62
+
63
+ opts.on('-s', '--select', 'Select topic from menu') do
64
+ Howzit.options[:choose] = true
65
+ end
66
+
67
+ opts.on('-T', '--task-list', 'List topics containing @ directives (completion-compatible)') do
68
+ Howzit.options[:list_runnable] = true
69
+ Howzit.options[:list_runnable_titles] = true
70
+ end
71
+
72
+ opts.on('-t', '--title', 'Output title with build notes') do
73
+ Howzit.options[:output_title] = true
74
+ end
75
+
76
+ opts.on('-q', '--quiet', 'Silence info message') do
77
+ Howzit.options[:log_level] = 3
78
+ end
79
+
80
+ opts.on('-v', '--verbose', 'Show all messages') do
81
+ Howzit.options[:log_level] = 0
82
+ end
83
+
84
+ opts.on('-u', '--[no-]upstream', 'Traverse up parent directories for additional build notes') do |p|
85
+ Howzit.options[:include_upstream] = p
86
+ end
87
+
88
+ opts.on('--show-code', 'Display the content of fenced run blocks') do
89
+ Howzit.options[:show_all_code] = true
90
+ end
91
+
92
+ opts.on('-w', '--wrap COLUMNS', 'Wrap to specified width (default 80, 0 to disable)') do |w|
93
+ Howzit.options[:wrap] = w.to_i
94
+ end
95
+
96
+ opts.on('--config-get [KEY]', 'Display the configuration settings or setting for a specific key') do |k|
97
+ if k.nil?
98
+ Howzit.options.sort_by { |key, _| key }.each do |key, val|
99
+ print "#{key}: "
100
+ p val
101
+ end
102
+ else
103
+ k.sub!(/^:/, '')
104
+ if Howzit.options.key?(k.to_sym)
105
+ puts Howzit.options[k.to_sym]
106
+ else
107
+ puts "Key #{k} not found"
108
+ end
109
+ end
110
+ Process.exit 0
111
+ end
112
+
113
+ opts.on('--config-set KEY=VALUE', 'Set a config value (must be a valid key)') do |key|
114
+ raise 'Argument must be KEY=VALUE' unless key =~ /\S=\S/
115
+
116
+ parts = key.split(/=/)
117
+ k = parts[0].sub(/^:/, '')
118
+ v = parts[1..-1].join(' ')
119
+
120
+ if Howzit.options.key?(k.to_sym)
121
+ Howzit.options[k.to_sym] = v.to_config_value(Howzit.options[k.to_sym])
122
+ else
123
+ puts "Key #{k} not found"
124
+ end
125
+ Howzit.config.write_config(Howzit.options)
126
+ Process.exit 0
127
+ end
128
+
129
+ opts.on('--edit-config', "Edit configuration file using default $EDITOR") do
130
+ Howzit.config.editor
131
+ Process.exit 0
132
+ end
133
+
134
+ opts.on('--title-only', 'Output title only') do
135
+ Howzit.options[:output_title] = true
136
+ Howzit.options[:title_only] = true
137
+ end
138
+
139
+ opts.on('--templates', 'List available templates') do
140
+ Dir.chdir(Howzit.config.template_folder)
141
+ Dir.glob('*.md').each do |file|
142
+ template = File.basename(file, '.md')
143
+ puts Howzit::Color.template("{Mk}template:{Yk}#{template}{x}")
144
+ puts Howzit::Color.template("{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}")
145
+ metadata = file.extract_metadata
146
+ topics = Howzit.buildnote.read_file(file)
147
+ topics.each do |topic|
148
+ puts Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}")
149
+ end
150
+ if metadata.size > 0
151
+ meta = []
152
+ meta << metadata['required'].split(/\s*,\s*/).map {|m| "*{bw}#{m}{xw}" } if metadata.key?('required')
153
+ meta << metadata['optional'].split(/\s*,\s*/).map {|m| "#{m}" } if metadata.key?('optional')
154
+ puts Howzit::Color.template("{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}")
155
+ puts Howzit::Color.template(" {bk}│ {xw}#{meta.join(", ")}{x}")
156
+ end
157
+ puts Howzit::Color.template(" {bk}└───────────────────────────────────────────┘{x}")
158
+ end
159
+ Process.exit 0
160
+ end
161
+
162
+ opts.on('--header-format TYPE', HEADER_FORMAT_OPTIONS,
163
+ "Formatting style for topic titles (#{HEADER_FORMAT_OPTIONS.join(', ')})") do |t|
164
+ Howzit.options[:header_format] = t
165
+ end
166
+
167
+ opts.on('--[no-]color', 'Colorize output (default on)') do |c|
168
+ Howzit.options[:color] = c
169
+ Howzit.options[:highlight] = false unless c
170
+ end
171
+
172
+ opts.on('--[no-]md-highlight', 'Highlight Markdown syntax (default on), requires mdless or mdcat') do |m|
173
+ Howzit.options[:highlight] = Howzit.options[:color] ? m : false
174
+ end
175
+
176
+ opts.on('--[no-]pager', 'Paginate output (default on)') do |p|
177
+ Howzit.options[:paginate] = p
178
+ end
179
+
180
+ opts.on('-h', '--help', 'Display this screen') do
181
+ puts opts
182
+ Process.exit 0
183
+ end
184
+
185
+ opts.on('-v', '--version', 'Display version number') do
186
+ puts "how v#{Howzit::VERSION}"
187
+ Process.exit 0
188
+ end
189
+
190
+ opts.on('--default', 'Answer all prompts with default response') do
191
+ Howzit.options[:default] = true
192
+ end
193
+ end.parse!(args)
194
+
195
+ Howzit.options[:multiple_matches] = Howzit.options[:multiple_matches].to_sym
196
+ Howzit.options[:header_format] = Howzit.options[:header_format].to_sym
197
+
198
+ Howzit.cli_args = args
199
+ Howzit.buildnote.run