howzit 1.2.15 → 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: c2df5a80f8f5ab2a265c424015adbcda29a16050e28411a194cb7b4c7eecdf6f
4
- data.tar.gz: fe974160b092d27f9901e91ddaf5d83b6f1b0c494108e1bd12d23a865e05e56a
3
+ metadata.gz: 14bc9569ad9313ee45f42b23fb1181ad3c70c4c7d7c69d436feff9804035c3ac
4
+ data.tar.gz: e40a8f4ca0e99a8e68c6df996d24bcd121a1d69dde2780f3836237303cf85e2c
5
5
  SHA512:
6
- metadata.gz: d71faacd4a0d7ae0ce10e089302c2ef8d32ece37479c718690b48b3d969d6725018665299a63d787b36419131ccc8642e94a638580aa38030ec51191a1e29d45
7
- data.tar.gz: 997f94412dd2f580ca712aead5d8609fa71044744c5ed0d4437d161331ae9ff58ad5f28f61ed8b969eca158551e131b730285b7e920c5f6347e4641db816385e
6
+ metadata.gz: bfa974d861fe4d225239d8b4ed496a46feeba3048b7b1eba4ec61bc5fdc5ad33e46cd1dab97dcf4553b64b916bf59cb28a8d1f3605cff6a7d222752266e0e644
7
+ data.tar.gz: 02c3c096d1841122c1e027274912b233e167a073c711945cad72186741e759f1c007d421a5accee7c86c0474742a033789e076a53d4858852c673317ccd0b56b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
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
+
1
13
  ### 1.2.15
2
14
 
3
15
  2022-08-02 11:59
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