howzit 2.0.6 → 2.0.9

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: 99e8c7d76873acb118176001c8ff721dc9ed193587d5d9c7ef6875f3a537bf56
4
- data.tar.gz: 6b969ea8400973fd90ac096d4a7a22a98fbcfee63e478f6d8963d37d3f1b5ce1
3
+ metadata.gz: e11e4e9f19c26666de0d9dbfbfd0ab1b3c1bee495575fe0962ab5157a185e613
4
+ data.tar.gz: 7430c1da6d45f7dc873e01a8c1e6618da2dab503659921b9b72d690ad7aff181
5
5
  SHA512:
6
- metadata.gz: 216b6dd76366a6add390d8604eb7fed21a074d607ec86347a4b06b410c3a3ba91c0eb56391a31dc40d90ae7c434c1812bd08e137f92350e487cd8e6629fdb836
7
- data.tar.gz: 17fcb459b9ba39dd8fb2647a9072defe684887f7c53decb940f3f606dd36c98c3fdf3868eb7cb42bcf5d969e22c82b014e4510b7c1baed878c79f402003c90fe
6
+ metadata.gz: 739879dd1a53689e005511745003dd9b9d2ff5a8fa964cec3cb1754ef78e740c488d0a9040cee6b6de5e5eaf62a4a9c50dcc74a236db732e1c78ef4f9c8978cd
7
+ data.tar.gz: '009601634be888e709ee5709fc2bb990b5dff1a274144469621a9b23dc5108778fec2f8838fc46f03999df8c31d9872f3ad8b9de57afb6bb534035a8f8070c25'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ ### 2.0.9
2
+
3
+ 2022-08-05 07:29
4
+
5
+ #### IMPROVED
6
+
7
+ - Avoid error trace on interrupt
8
+ - Better stty settings for y/n prompt
9
+ - Better coloring of default options in dialogs
10
+
11
+ #### FIXED
12
+
13
+ - Encoding issues with older ruby versions
14
+ - Globbing for build notes was picking up files that contained "build" but not at the beginning of the filename
15
+
16
+ ### 2.0.8
17
+
18
+ 2022-08-04 13:28
19
+
20
+ #### FIXED
21
+
22
+ - Bugfixes
23
+
24
+ ### 2.0.7
25
+
26
+ 2022-08-04 13:04
27
+
28
+ #### NEW
29
+
30
+ - --debug flag (shortcut for :log_level: 0)
31
+
32
+ #### IMPROVED
33
+
34
+ - Console output now gets log levels, so :log_level: config option and --quiet/verbose have more utility
35
+
1
36
  ### 2.0.6
2
37
 
3
38
  2022-08-04 11:08
data/README.md CHANGED
@@ -37,340 +37,9 @@ You can install `howzit` by running:
37
37
 
38
38
  gem install howzit
39
39
 
40
- ## Anatomy of a Build Notes File
40
+ ### Usage
41
41
 
42
- Howzit relies on there being a file in the current directory with a name that starts with "build" or "howzit" and an extension of `.md`, `.txt`, or `.markdown`, e.g. `buildnotes.md` or `howzit.txt`. This note contains topics such as "Build" and "Deploy" with brief notes about each topic in Markdown (or just plain text) format.
43
-
44
- > Tip: Add "buildprivate.md" to your global gitignore (`git config --get core.excludesfile`). In a project where you don't want to share your build notes, just name the file "buildprivate.md" instead of "buildnotes.md" and it will automatically be ignored.
45
-
46
- If there are files that match the "build*" pattern that should not be recognized as build notes by howzit, add them to `~/.config/howzit/ignore.yaml`. This file is a simple list of patterns that should be ignored when scanning for build note files. Use `(?:i)` at the beginning of a pattern to make it case insensitive.
47
-
48
- The topics of the notes are delineated by Markdown headings, level 2 or higher, with the heading being the title of the topic. I split all of mine apart with h2s. For example, a short one from the little website I was working on yesterday:
49
-
50
- ## Build
51
-
52
- gulp js: compiles and minifies all js to dist/js/main.min.js
53
-
54
- gulp css: compass compile to dist/css/
55
-
56
- gulp watch
57
-
58
- gulp (default): [css,js]
59
-
60
- ## Deploy
61
-
62
- gulp sync: rsync /dist/ to scoffb.local
63
-
64
- ## Package management
65
-
66
- yarn
67
-
68
- ## Components
69
-
70
- - UIKit
71
-
72
- Howzit expects there to only be one header level used to split topics. Anything before the first header is ignored. If your topics use h2 (`##`), you can use a single h1 (`#`) line at the top to title the project.
73
-
74
- ### @Commands
75
-
76
- You can include commands that can be executed by howzit. Commands start at the beginning of a line anywhere in a topic. Only one topic's commands can be run at once, but all commands in the topic will be executed when howzit is run with `-r`. Commands can include any of:
77
-
78
- - `@run(COMMAND)`
79
-
80
- The command in parenthesis will be executed as is from the current directory of the shell
81
- - `@copy(TEXT)`
82
-
83
- On macOS this will copy the text within the parenthesis to the clipboard. An easy way to offer a shortcut to a longer build command while still allowing it to be edited prior to execution.
84
- - `@open(FILE|URL)`
85
-
86
- Will open the file or URL using the default application for the filetype. On macOS this uses the `open` command, on Windows it uses `start`, and on Linux it uses `xdg-open`, which may require separate installation.
87
- - `@include(TOPIC)`
88
-
89
- Includes all tasks from another topic, matching the name (partial match allowed) and returning first match.
90
- - `@before...@end`
91
-
92
- A block defined between @before and @end markers will be considered prerequisite for any task the topic can run. If one or more of these blocks exist in the topic, they will be displayed before running and a yes/no dialog will request confirmation that the prerequisites have been met. The content between these markers is still included when viewing the topic, but the tags themselves do not show up in output.
93
- - `@after...@end`
94
-
95
- A block defined between @after and @end markers will be displayed after a topic is run. Use it to remind yourself of additional tasks after automated ones have been executed. The content between these markers is still included when viewing the topic, but the tags themselves do not show up in output.
96
-
97
- ### Adding Titles
98
-
99
- When displaying a topic, howzit can display a title instead of the contents of a directive. Any text after the closing parenthesis will be considered the task title.
100
-
101
- ```
102
- @run(~/scripts/deploy.sh) Deploy script
103
- ```
104
-
105
- When the topic is displayed, it will now show "Run Deploy script" instead of the path to the script. This can be overridden with the `--show-code` flag, which will instead show the contents of the directive.
106
-
107
- For adding titles to run blocks (fenced code), see below.
108
-
109
- ### Run blocks (embedded scripts)
110
-
111
- For longer scripts you can write shell scripts and then call them with `@run(myscript.sh)`. For those in-between cases where you need a few commands but aren't motivated to create a separate file, you can use fenced code blocks with `run` as the language.
112
-
113
- ```run OPTIONAL TITLE
114
- #!/bin/bash
115
- # Commands...
116
- ```
117
-
118
- The contents of the block will be written to a temporary file and executed with `/bin/sh -c`. This means that you need a hashbang at the beginning to tell the shell how to interpret the script. If no hashbang is given, the script will be executed as a `sh` script.
119
-
120
- Example:
121
-
122
- ```run Just Testing
123
- #!/bin/bash
124
- echo "Just needed a few lines"
125
- echo "To get through all these commands"
126
- echo "Almost there!"
127
- say "Phew, we did it."
128
- ```
129
-
130
- Multiple blocks can be included in a topic. @commands take priority over code blocks and will be run first if they exist in the same topic.
131
-
132
- ### Requiring Confirmation
133
-
134
- You can have howzit confirm whether to execute an @command at runtime by including a question mark to the directive, e.g. `@run?(...)`. This will present a yes/no dialog before running the directive, with a default response of "yes" if you just hit return. To make the default response "no," add an exclamation point, e.g. `@run?!(...)`.
135
-
136
- This works for any directive, including `@include`, and run blocks, which can use `run?` as the language specifier.
137
-
138
- ### Variables
139
-
140
- When running commands in a topic, you can use a double dash (`--`) in the command line (surrounded by spaces) and anything after it will be interpreted as shell arguments. These can be used in commands with `$` placeholders. `$1` represents the first argument, counting up from there. Use `$@` to pass all arguments as a shell-escaped string.
141
-
142
- For example, the topic titled "Test" could contain an @run command with placeholders:
143
-
144
- ## Test
145
- @run(./myscript.sh $@)
146
-
147
- Then you would run it on the command line using:
148
-
149
- howzit -r test -- -x "arg 1" arg2
150
-
151
- This would execute the command as `./myscript.sh -x arg\ 1 arg2`.
152
-
153
- Placeholders can be used in both commands and run blocks. If a placeholder doesn't have an argument supplied, it's not replaced (e.g. leaves `$2` in the command).
154
-
155
- ### Templates and metadata
156
-
157
- You can create templates to reuse topics in multiple build note files. Create files using the same formatting as a build note in `~/.config/howzit/templates` with `.md` extensions. Name them the way you'll reference them:
158
-
159
- ~/.config/howzit/templates
160
- - markdown.md
161
- - ruby.md
162
- - obj-c.md
163
-
164
- > Use `howzit --templates` for a list of templates you've created, along with the topics they'll add when included. Just in case you make a bunch and can't remember what they're called or what they do. I was just planning ahead.
165
-
166
- You can then include the topics from a template in any build note file using a `template:` key at the top of the file.
167
-
168
- Howzit allows MultiMarkdown-style metadata at the top of a build notes file. These are key/value pairs separated by a colon:
169
-
170
- template: markdown
171
- key 1: value 1
172
- key 2: value 2
173
-
174
- The template key can include multiple template names separated by commas.
175
-
176
- Additional metadata keys populate variables you can then use inside of your templates (and build notes), using `[%key]`. You can define a default value for a placeholder with `[%key:default]`.
177
-
178
- For example, in the template `markdown.md` you could have:
179
-
180
- ### Spellcheck
181
-
182
- Check spelling of all Markdown files in git repo.
183
-
184
- ```run
185
- #!/bin/bash
186
- for dir in [%dirs:.]; do
187
- cd "$dir"
188
- /Users/ttscoff/scripts/spellcheck.bash
189
- cd -
190
- done
191
- ```
192
-
193
- Then, in a `buildnotes.md` file in your project, you could include at the top of the file:
194
-
195
- template: markdown
196
- dirs: . docs
197
-
198
- # My Project...
199
-
200
- If you only want to include certain topics from a template file, use the format `template_name[topic]` or include multiple topics separated by commas: `template_name[topic 1, topic 2]`. You can also use `*` as a wildcard, where `template_name[build*]` would include topics "Build" and "Build and Run".
201
-
202
- If a topic in the current project's build note has an identical name to a template topic, the local topic takes precedence. This allows you to include a template but modify just a part of it by duplicating the topic title.
203
-
204
- Templates can include other templates with a `template:` key at the top of the template.
205
-
206
- You can define what metadata keys are required for the template using a `required:` key at the top of the template. For example, if the template `script.md` uses a placeholder `[%executable]` that can't have a default value as it's specific to each project, you can add:
207
-
208
- required: executable
209
-
210
- at the top of `project.md`. If the template is included in a build notes file and the `executable:` key is not defined, an error will be shown.
211
-
212
- ## Using howzit
213
-
214
- Run `howzit` on its own to view the current folder's buildnotes.
215
-
216
- Include a topic name to see just that topic, or no argument to display all.
217
-
218
- howzit build
219
-
220
- 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.
221
-
222
- howzit build,deploy
223
-
224
- Use `-l` to list all topics.
225
-
226
- howzit -l
227
-
228
- Use `-r` to execute any @copy, @run, or @open commands in the given topic. Options can come after the topic argument, so to run the commands from the last topic you viewed, just hit the up arrow to load the previous command and add `-r`.
229
-
230
- howzit build -r
231
-
232
- Other options:
233
-
234
- Usage: howzit [OPTIONS] [TOPIC]
235
-
236
- Show build notes for the current project (buildnotes.md). Include a topic name to see just that topic, or no argument to display all.
237
-
238
- Options:
239
- -c, --create Create a skeleton build note in the current working directory
240
- -e, --edit Edit buildnotes file in current working directory
241
- using $EDITOR
242
- --grep PATTERN Display sections matching a search pattern
243
- -L, --list-completions List topics for completion
244
- -l, --list List available topics
245
- -m, --matching TYPE Topics matching type
246
- (partial, exact, fuzzy, beginswith)
247
- --multiple TYPE Multiple result handling
248
- (first, all, choose)
249
- -R, --list-runnable List topics containing @ directives (verbose)
250
- -r, --run Execute @run, @open, and/or @copy commands for given topic
251
- -s, --select Select topic from menu
252
- -T, --task-list List topics containing @ directives (completion-compatible)
253
- -t, --title Output title with build notes
254
- -q, --quiet Silence info message
255
- --verbose Show all messages
256
- -u, --[no-]upstream Traverse up parent directories for additional build notes
257
- --show-code Display the content of fenced run blocks
258
- -w, --wrap COLUMNS Wrap to specified width (default 80, 0 to disable)
259
- --edit-config Edit configuration file using default $EDITOR
260
- --title-only Output title only
261
- --templates List available templates
262
- --[no-]color Colorize output (default on)
263
- --[no-]md-highlight Highlight Markdown syntax (default on), requires mdless or mdcat
264
- --[no-]pager Paginate output (default on)
265
- -h, --help Display this screen
266
- -v, --version Display version number
267
- --default Answer all prompts with default response
268
-
269
-
270
- ## Configuration
271
-
272
- Some of the command line options can be set as defaults. The first time you run `howzit`, a YAML file is written to `~/.config/howzit/howzit.yaml`. You can open it in your default editor automatically by running `howzit --edit-config`. It contains the available options:
273
-
274
- ---
275
- :color: true
276
- :highlight: true
277
- :paginate: true
278
- :wrap: 80
279
- :output_title: false
280
- :highlighter: auto
281
- :pager: auto
282
- :matching: partial
283
- :include_upstream: false
284
- :log_level: 1
285
- :multiple_matches: choose
286
- :header_format: border
287
-
288
- If `:color:` is false, output will not be colored, and markdown highlighting will be bypassed.
289
-
290
- If `:color:` is true and `:highlight:` is true, the `:highlighter:` option will be used to add Markdown highlighting.
291
-
292
- If `:paginate:` is true, the `:pager:` option will be used to determine the tool used for pagination. If it's false and you're using iTerm, "marks" will be added to topic titles allowing keyboard navigation.
293
-
294
- `:highlighter:` and `:pager:` can be set to `auto` (default) or a command of your choice for markdown highlighting and pagination.
295
-
296
- `:matching:` can be "partial", "beginswith", "fuzzy" or "exact" (see below).
297
-
298
- If `:include_upstream:` is true, build note files in parent directories will be included in addition to the current directory. Priority goes from current directory to root in descending order, so the current directory is top priority, and a build notes file in / is the lowest. Higher priority topics will not be overwritten by a duplicate topic from a lower priority note.
299
-
300
- Set `:log_level:` to 0 for debug messages, or 3 to suppress superfluous info messages.
301
-
302
- `: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.
303
-
304
- `: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.
305
-
306
- ### Matching
307
-
308
- All matching is case insensitive. This setting can be overridden by the `--matching TYPE` flag on the command line.
309
-
310
- - `:matching: partial`
311
-
312
- Partial is the default, search matches any part of the topic title.
313
-
314
- _Example:_ `howzit other` matches 'An<mark>other</mark> Topic'.
315
-
316
- - `:matching: beginswith`
317
-
318
- Matches from the start of the title.
319
-
320
- _Example:_ `howzit another` matches '<mark>Another</mark> Topic', but neither 'other' or 'topic' will.
321
-
322
- - `:matching: fuzzy`
323
-
324
- Matches anything containing the search characters in order, no matter what comes between them.
325
-
326
- _Example:_ `howzit asct` matches '<mark>A</mark>nother <mark>S</mark>e<mark>c</mark><mark>t</mark>ion'
327
-
328
- - `:matching: exact`
329
-
330
- Case insensitive but must match the entire title.
331
-
332
- _Example:_ Only `howzit another topic` will match 'Another Topic'
333
-
334
- ### Pager
335
-
336
- If set to `auto`, howzit will look for pagers in this order, using the first one it finds available:
337
-
338
- - $GIT_PAGER
339
- - $PAGER
340
- - bat
341
- - less
342
- - more
343
- - cat
344
- - pager
345
-
346
- If you're defining your own, make sure to include any flags necessary to handle the output. If you're using howzit's coloring, for example, you need to specify any options needed to display ANSI escape sequences (e.g. `less -r`).
347
-
348
- ### Highlighter
349
-
350
- If set to `auto` howzit will look for markdown highlighters in this order, using the first it finds available:
351
-
352
- - mdcat
353
- - mdless
354
-
355
- If you're combining a highlighter with howzit's pagination, include any flags needed to disable the highlighter's pagination (e.g. `mdless --no-pager`).
356
-
357
- ## Shell Integration
358
-
359
- I personally like to alias `bld` to `howzit -r`. If you define a function in your shell, you can have it default to "build" but accept an alternate argument. There's an example for Fish included, and in Bash it would be as simple as `howzit -r ${1:build}`.
360
-
361
- For completion you can use `howzit -L` to list all topics, and `howzit -T` to list all "runnable" topics (topics containing an @directive or run block). Completion examples for Fish are included in the `fish` directory.
362
-
363
- ## Similar Projects
364
-
365
- - [mask](https://github.com/jakedeichert/mask/)
366
- - [maid](https://github.com/egoist/maid)
367
- - [saku](https://github.com/kt3k/saku)
368
-
369
- There are a few projects that tackle the same concept (a Markdown makefile). Most of them are superior task runners, so if you're looking for a `make` replacement, I recommend exploring the links above. What I like about `howzit` (and what keeps me from switching) is that it's documentation-first, and that I can display the description for each topic on the command line. The others also don't have options for listing topics or runnable tasks, so I can't use completion (or my cool script that adds available tasks to my Macbook Pro Touch Bar...). But no, I don't think `howzit` is as good an overall task runner as `mask` or `maid`.
370
-
371
- ## Roadmap
372
-
373
- - Recognize header hierarchy, allow showing/running all sub-topics
42
+ [See the wiki](https://github.com/ttscoff/howzit/wiki) for documentation.
374
43
 
375
44
  ## Author
376
45
 
@@ -391,9 +60,11 @@ purpose.
391
60
 
392
61
  ## Documentation
393
62
 
63
+ - [Howzit Wiki][Wiki].
394
64
  - [YARD documentation][RubyDoc] is hosted by RubyDoc.info.
395
65
  - [Interactive documentation][Omniref] is hosted by Omniref.
396
66
 
67
+ [Wiki]: https://github.com/ttscoff/howzit/wiki
397
68
  [RubyDoc]: http://www.rubydoc.info/gems/howzit
398
69
  [Omniref]: https://www.omniref.com/ruby/gems/howzit
399
70
 
data/bin/howzit CHANGED
@@ -18,28 +18,10 @@ OptionParser.new do |opts|
18
18
  opts.separator ''
19
19
  opts.separator 'Options:'
20
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
21
+ opts.separator " Behavior:\n\n" #=================================================================== BEHAVIOR
31
22
 
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
23
+ opts.on('--default', 'Answer all prompts with default response') do
24
+ Howzit.options[:default] = true
43
25
  end
44
26
 
45
27
  opts.on('-m', '--matching TYPE', MATCHING_OPTIONS,
@@ -52,45 +34,63 @@ OptionParser.new do |opts|
52
34
  Howzit.options[:multiple_matches] = c.to_sym
53
35
  end
54
36
 
55
- opts.on('-R', '--list-runnable', 'List topics containing @ directives (verbose)') do
56
- Howzit.options[:list_runnable] = true
37
+ opts.on('-u', '--[no-]upstream', 'Traverse up parent directories for additional build notes') do |p|
38
+ Howzit.options[:include_upstream] = p
57
39
  end
58
40
 
59
- opts.on('-r', '--run', 'Execute @run, @open, and/or @copy commands for given topic') do
60
- Howzit.options[:run] = true
61
- end
41
+ opts.separator "\n Listing:\n\n" #=================================================================== LISTING
62
42
 
63
- opts.on('-s', '--select', 'Select topic from menu') do
64
- Howzit.options[:choose] = true
43
+ opts.on('-L', '--list-completions', 'List topics for completion') do
44
+ Howzit.options[:list_topics] = true
45
+ Howzit.options[:list_topic_titles] = true
65
46
  end
66
47
 
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
48
+ opts.on('-l', '--list', 'List available topics') do
49
+ Howzit.options[:list_topics] = true
70
50
  end
71
51
 
72
- opts.on('-t', '--title', 'Output title with build notes') do
73
- Howzit.options[:output_title] = true
52
+ opts.on('-R', '--list-runnable', 'List topics containing @ directives (verbose)') do
53
+ Howzit.options[:list_runnable] = true
74
54
  end
75
55
 
76
- opts.on('-q', '--quiet', 'Silence info message') do
77
- Howzit.options[:log_level] = 3
56
+ opts.on('-T', '--task-list', 'List topics containing @ directives (completion-compatible)') do
57
+ Howzit.options[:list_runnable] = true
58
+ Howzit.options[:list_runnable_titles] = true
78
59
  end
79
60
 
80
- opts.on('-v', '--verbose', 'Show all messages') do
81
- Howzit.options[:log_level] = 0
61
+ opts.on('--templates', 'List available templates') do
62
+ Dir.chdir(Howzit.config.template_folder)
63
+ Dir.glob('*.md').each do |file|
64
+ template = File.basename(file, '.md')
65
+ puts Howzit::Color.template("{Mk}template:{Yk}#{template}{x}")
66
+ puts Howzit::Color.template('{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}')
67
+ metadata = file.extract_metadata
68
+ topics = Howzit.buildnote.read_file(file)
69
+ topics.each do |topic|
70
+ puts Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}")
71
+ end
72
+ unless metadata.empty?
73
+ meta = []
74
+ meta << metadata['required'].split(/\s*,\s*/).map { |m| "*{bw}#{m}{xw}" } if metadata.key?('required')
75
+ meta << metadata['optional'].split(/\s*,\s*/).map(&:to_s) if metadata.key?('optional')
76
+ puts Howzit::Color.template('{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}')
77
+ puts Howzit::Color.template(" {bk}│ {xw}#{meta.join(', ')}{x}")
78
+ end
79
+ puts Howzit::Color.template(' {bk}└───────────────────────────────────────────┘{x}')
80
+ end
81
+ Process.exit 0
82
82
  end
83
83
 
84
- opts.on('-u', '--[no-]upstream', 'Traverse up parent directories for additional build notes') do |p|
85
- Howzit.options[:include_upstream] = p
84
+ opts.on('--title-only', 'Output title only') do
85
+ Howzit.options[:output_title] = true
86
+ Howzit.options[:title_only] = true
86
87
  end
87
88
 
88
- opts.on('--show-code', 'Display the content of fenced run blocks') do
89
- Howzit.options[:show_all_code] = true
90
- end
89
+ opts.separator("\n Commands:\n\n") #=================================================================== COMMANDS
91
90
 
92
- opts.on('-w', '--wrap COLUMNS', 'Wrap to specified width (default 80, 0 to disable)') do |w|
93
- Howzit.options[:wrap] = w.to_i
91
+ opts.on('-c', '--create', 'Create a skeleton build note in the current working directory') do
92
+ Howzit.buildnote.create_note
93
+ Process.exit 0
94
94
  end
95
95
 
96
96
  opts.on('--config-get [KEY]', 'Display the configuration settings or setting for a specific key') do |k|
@@ -126,49 +126,41 @@ OptionParser.new do |opts|
126
126
  Process.exit 0
127
127
  end
128
128
 
129
- opts.on('--edit-config', 'Edit configuration file using default $EDITOR') do
129
+ opts.on('--edit-config', "Edit configuration file using editor (#{Howzit.options[:editor]})") do
130
130
  Howzit.config.editor
131
131
  Process.exit 0
132
132
  end
133
133
 
134
- opts.on('--title-only', 'Output title only') do
135
- Howzit.options[:output_title] = true
136
- Howzit.options[:title_only] = true
134
+ desc = %(Edit buildnotes file in current working directory using editor (#{Howzit.options[:config_editor]}))
135
+ opts.on('-e', '--edit', desc) do
136
+ Howzit.buildnote.edit
137
+ Process.exit 0
137
138
  end
138
139
 
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
140
+ opts.on('--grep PATTERN', 'Display sections matching a search pattern') do |pat|
141
+ Howzit.options[:grep] = pat
160
142
  end
161
143
 
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
144
+ opts.on('-r', '--run', 'Execute @run, @open, and/or @copy commands for given topic') do
145
+ Howzit.options[:run] = true
165
146
  end
166
147
 
148
+ opts.on('-s', '--select', 'Select topic from menu') do
149
+ Howzit.options[:choose] = true
150
+ end
151
+
152
+ opts.separator("\n Formatting:\n\n") #=================================================================== FORMATTING
153
+
167
154
  opts.on('--[no-]color', 'Colorize output (default on)') do |c|
168
155
  Howzit.options[:color] = c
169
156
  Howzit.options[:highlight] = false unless c
170
157
  end
171
158
 
159
+ opts.on('--header-format TYPE', HEADER_FORMAT_OPTIONS,
160
+ "Formatting style for topic titles (#{HEADER_FORMAT_OPTIONS.join(', ')})") do |t|
161
+ Howzit.options[:header_format] = t
162
+ end
163
+
172
164
  opts.on('--[no-]md-highlight', 'Highlight Markdown syntax (default on), requires mdless or mdcat') do |m|
173
165
  Howzit.options[:highlight] = Howzit.options[:color] ? m : false
174
166
  end
@@ -177,6 +169,37 @@ OptionParser.new do |opts|
177
169
  Howzit.options[:paginate] = p
178
170
  end
179
171
 
172
+ opts.on('--show-code', 'Display the content of fenced run blocks') do
173
+ Howzit.options[:show_all_code] = true
174
+ end
175
+
176
+ opts.on('-t', '--title', 'Output title with build notes') do
177
+ Howzit.options[:output_title] = true
178
+ end
179
+
180
+ opts.on('-w', '--wrap COLUMNS', 'Wrap to specified width (default 80, 0 to disable)') do |w|
181
+ Howzit.options[:wrap] = w.to_i
182
+ end
183
+
184
+ opts.separator("\n Logging:\n\n") #=================================================================== LOGGING
185
+
186
+ opts.on('-d', '--debug', 'Show debug messages (and all messages)') do
187
+ Howzit.options[:log_level] = 0
188
+ Howzit.console.reset_level
189
+ end
190
+
191
+ opts.on('-q', '--quiet', 'Silence info message') do
192
+ Howzit.options[:log_level] = 4
193
+ Howzit.console.reset_level
194
+ end
195
+
196
+ opts.on('--verbose', 'Show all messages') do
197
+ Howzit.options[:log_level] = 1
198
+ Howzit.console.reset_level
199
+ end
200
+
201
+ opts.separator("\n Misc:\n\n") #=================================================================== MISC
202
+
180
203
  opts.on('-h', '--help', 'Display this screen') do
181
204
  puts opts
182
205
  Process.exit 0
@@ -186,12 +209,14 @@ OptionParser.new do |opts|
186
209
  puts "how v#{Howzit::VERSION}"
187
210
  Process.exit 0
188
211
  end
189
-
190
- opts.on('--default', 'Answer all prompts with default response') do
191
- Howzit.options[:default] = true
192
- end
193
212
  end.parse!(args)
194
213
 
214
+ trap('INT') do
215
+ puts
216
+ puts 'Cancelled'
217
+ Process.exit 0
218
+ end
219
+
195
220
  Howzit.options[:multiple_matches] = Howzit.options[:multiple_matches].to_sym
196
221
  Howzit.options[:header_format] = Howzit.options[:header_format].to_sym
197
222
 
data/howzit.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_development_dependency 'rubocop', '~> 0.28'
32
32
  spec.add_development_dependency 'rspec', '~> 3.1'
33
+ spec.add_development_dependency 'cli-test', '~> 1.0'
33
34
  spec.add_development_dependency 'simplecov', '~> 0.9'
34
35
  # spec.add_development_dependency 'codecov', '~> 0.1'
35
36
  spec.add_development_dependency 'fuubar', '~> 2.0'
@@ -40,5 +41,6 @@ Gem::Specification.new do |spec|
40
41
 
41
42
  spec.add_runtime_dependency 'mdless', '~> 1.0', '>= 1.0.28'
42
43
  spec.add_runtime_dependency 'tty-screen', '~> 0.8'
44
+ spec.add_runtime_dependency 'tty-box', '~> 0.7'
43
45
  # spec.add_runtime_dependency 'tty-prompt', '~> 0.23'
44
46
  end