howzit 1.2.15 → 1.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +29 -0
- data/bin/howzit +193 -2
- data/lib/howzit/buildnote.rb +543 -0
- data/lib/howzit/buildnotes.rb +0 -1
- data/lib/howzit/colors.rb +2 -2
- data/lib/howzit/config.rb +128 -0
- data/lib/howzit/hash.rb +35 -0
- data/lib/howzit/prompt.rb +84 -11
- data/lib/howzit/stringutils.rb +54 -8
- data/lib/howzit/task.rb +22 -0
- data/lib/howzit/topic.rb +235 -0
- data/lib/howzit/util.rb +149 -0
- data/lib/howzit/version.rb +1 -1
- data/lib/howzit.rb +40 -5
- data/spec/ruby_gem_spec.rb +87 -17
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574fddfbc584d44f9b1f9c6abaaaf16ac5b5d1115b303ba714269210c332e843
|
4
|
+
data.tar.gz: 94d81054906fc579ff104cbc917e0d85b005723d02bd84d59430bb1e340513bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f8acd5969c1943d675dd149b7b02e4942933eaa988de6046885d2b5536d81ef3fc91e9dab06b2f7a3bcc4a2b8896d408e0ca6cb963f54dcc0aec35fa78f537
|
7
|
+
data.tar.gz: 193995fa9d533b1937a390fe11cca96459f1a97bd259e31b7a5bb70aabc85261da2c77349b5af00655b45356a43fe0e6d297469d7b2772b1ff0eb4c4b0760912
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
### 1.2.18
|
2
|
+
|
3
|
+
2022-08-03 12:13
|
4
|
+
|
5
|
+
#### FIXED
|
6
|
+
|
7
|
+
- Unwritable content property
|
8
|
+
|
9
|
+
### 1.2.17
|
10
|
+
|
11
|
+
2022-08-03 12:10
|
12
|
+
|
13
|
+
#### FIXED
|
14
|
+
|
15
|
+
- Variables in topics not being replaced with metadata
|
16
|
+
- Allow default response in yes/no prompt
|
17
|
+
|
18
|
+
### 1.2.16
|
19
|
+
|
20
|
+
2022-08-03 11:41
|
21
|
+
|
22
|
+
#### IMPROVED
|
23
|
+
|
24
|
+
- Complete code refactoring
|
25
|
+
|
26
|
+
#### FIXED
|
27
|
+
|
28
|
+
- Multiple includes of upstream files when templates are specified
|
29
|
+
|
1
30
|
### 1.2.15
|
2
31
|
|
3
32
|
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
|
-
|
8
|
-
|
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
|