howzit 1.2.14 → 1.2.17

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: 3858dec6b009f75173d3d72067a94c330cb826b0e367109c7416b2db19065fa8
4
- data.tar.gz: 2e05520b1ff9d5da82aba03b1af3ed31ee0a635f3fe42c50b3a515c45337c38b
3
+ metadata.gz: f1d8a45dca4630f76f10fd6f410c63fd4e1685844ca895231d9910717ca97d9b
4
+ data.tar.gz: 27476b1f987f6f1555e81f14270e923867d75519f5c25d3241a104ec861ddbe3
5
5
  SHA512:
6
- metadata.gz: 90cb7e647c7956823e73eac6e4884a1ffe26875acd531cc70be6a1b334aa9653213cafbf0830cd69a634579c7fa61553585bbbc95f997a02b0192d093a85be1b
7
- data.tar.gz: bfba515bc66d5f15ae33d967866e83e2e9e4c887160d0c66269542ee909acf8383742fd0e64f5639013a1ccdc16253664a3c90cd150fd5a67529280473ed1a88
6
+ metadata.gz: f3105ab63cc58b59f488f10a9717b457892b83b10760a303364bd9d790d7bb3630d30663ad6232979ce8dbab361c4ba67ee837009cc2f53c12c6bbb2035b8eca
7
+ data.tar.gz: 661c54c86f55cbe939001b30848c3c35e7779571bb9a5797af96c107db761322cd37f11c2bf4d0e2b61d65173c9855735296fe46f029283845fd5a1c19f61103
data/.rubocop.yml CHANGED
@@ -4,6 +4,11 @@ AllCops:
4
4
  - Guardfile
5
5
  - Rakefile
6
6
 
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - bin/howzit
10
+ - lib/*.rb
11
+
7
12
  Style/RegexpLiteral:
8
13
  Exclude:
9
14
  - Guardfile
data/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ### 1.2.17
2
+
3
+ 2022-08-03 12:10
4
+
5
+ #### FIXED
6
+
7
+ - Variables in topics not being replaced with metadata
8
+ - Allow default response in yes/no prompt
9
+
10
+ ### 1.2.16
11
+
12
+ 2022-08-03 11:41
13
+
14
+ #### IMPROVED
15
+
16
+ - Complete code refactoring
17
+
18
+ #### FIXED
19
+
20
+ - Multiple includes of upstream files when templates are specified
21
+
22
+ ### 1.2.15
23
+
24
+ 2022-08-02 11:59
25
+
26
+ #### NEW
27
+
28
+ - Option to set :header_format: to block for alternate topic title appearance
29
+
30
+ #### FIXED
31
+
32
+ - Missing spacing around topic titles when displaying multiple topics
33
+
1
34
  ### 1.2.14
2
35
 
3
36
  2022-08-02 11:01
data/README.md CHANGED
@@ -265,6 +265,7 @@ Some of the command line options can be set as defaults. The first time you run
265
265
  :include_upstream: false
266
266
  :log_level: 1
267
267
  :multiple_matches: choose
268
+ :header_format: border
268
269
 
269
270
  If `:color:` is false, output will not be colored, and markdown highlighting will be bypassed.
270
271
 
@@ -282,6 +283,8 @@ Set `:log_level:` to 0 for debug messages, or 3 to suppress superfluous info mes
282
283
 
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.
284
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
+
285
288
  ### Matching
286
289
 
287
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
+ unless metadata.empty?
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(&:to_s) 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