howzit 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +18 -8
- data/bin/howzit +8 -1
- data/lib/howzit/buildnote.rb +3 -3
- data/lib/howzit/config.rb +2 -2
- data/lib/howzit/console_logger.rb +43 -0
- data/lib/howzit/prompt.rb +1 -1
- data/lib/howzit/task.rb +4 -0
- data/lib/howzit/topic.rb +13 -13
- data/lib/howzit/util.rb +3 -3
- data/lib/howzit/version.rb +1 -1
- data/lib/howzit.rb +6 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad8cdc085654826428d432429473e7b12375288058f3c0ce993f94937441485
|
4
|
+
data.tar.gz: 8dfda4d862d35559b0cd9a1e89c4a69597aa16ef9dba5dac29eff1ee61ed295a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec8eea72d9177717e0ed6dcd07c35d9eb12f998dabea1347efae1dca1fc145a8c5e4b8317f1cf4805606a86209e389643c959aa60deb240ebd2808ddbe456f4
|
7
|
+
data.tar.gz: a9f3e5472866af519bc053ab50ef3f6a5089ddc4334e9687cb64dd9a8e026d00a0b2bb12d1246631f209892de9bb03168cb05cbaa852d97c44734395b00b122b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
### 2.0.7
|
2
|
+
|
3
|
+
2022-08-04 13:04
|
4
|
+
|
5
|
+
#### NEW
|
6
|
+
|
7
|
+
- --debug flag (shortcut for :log_level: 0)
|
8
|
+
|
9
|
+
#### IMPROVED
|
10
|
+
|
11
|
+
- Console output now gets log levels, so :log_level: config option and --quiet/verbose have more utility
|
12
|
+
|
1
13
|
### 2.0.6
|
2
14
|
|
3
15
|
2022-08-04 11:08
|
data/README.md
CHANGED
@@ -273,17 +273,21 @@ Some of the command line options can be set as defaults. The first time you run
|
|
273
273
|
|
274
274
|
---
|
275
275
|
:color: true
|
276
|
+
:config_editor: subl
|
277
|
+
:editor: subl
|
278
|
+
:header_format: block
|
276
279
|
:highlight: true
|
277
|
-
:
|
278
|
-
:
|
280
|
+
:highlighter: mdcat
|
281
|
+
:include_upstream: true
|
282
|
+
:log_level: 0
|
283
|
+
:matching: fuzzy
|
284
|
+
:multiple_matches: choose
|
279
285
|
:output_title: false
|
280
|
-
:highlighter: auto
|
281
286
|
:pager: auto
|
282
|
-
:
|
283
|
-
:
|
284
|
-
:
|
285
|
-
:
|
286
|
-
:header_format: border
|
287
|
+
:paginate: true
|
288
|
+
:show_all_code: false
|
289
|
+
:show_all_on_error: false
|
290
|
+
:wrap: 0
|
287
291
|
|
288
292
|
If `:color:` is false, output will not be colored, and markdown highlighting will be bypassed.
|
289
293
|
|
@@ -354,6 +358,12 @@ If set to `auto` howzit will look for markdown highlighters in this order, using
|
|
354
358
|
|
355
359
|
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
360
|
|
361
|
+
### Configuring from the Command Line
|
362
|
+
|
363
|
+
You can get and set config options from the command line using `--config-get` and `--config-set`. If you run `--config-get` with no argument, it will display all config options. If you add a key (exact match required) you can get just the value for that key.
|
364
|
+
|
365
|
+
Using `--config-set` requires an argument in the format `key=value`. The type of the value (boolean, integer, string, symbol) will be automatically determined and converted. To change your highlighter, for example, use `howzit --config-set highlighter=mdcat`.
|
366
|
+
|
357
367
|
## Shell Integration
|
358
368
|
|
359
369
|
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}`.
|
data/bin/howzit
CHANGED
@@ -74,11 +74,18 @@ OptionParser.new do |opts|
|
|
74
74
|
end
|
75
75
|
|
76
76
|
opts.on('-q', '--quiet', 'Silence info message') do
|
77
|
-
Howzit.options[:log_level] =
|
77
|
+
Howzit.options[:log_level] = 4
|
78
|
+
Howzit.console.reset_level
|
78
79
|
end
|
79
80
|
|
80
81
|
opts.on('-v', '--verbose', 'Show all messages') do
|
82
|
+
Howzit.options[:log_level] = 1
|
83
|
+
Howzit.console.reset_level
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on('-d', '--debug', 'Show debug messages (and all messages)') do
|
81
87
|
Howzit.options[:log_level] = 0
|
88
|
+
Howzit.console.reset_level
|
82
89
|
end
|
83
90
|
|
84
91
|
opts.on('-u', '--[no-]upstream', 'Traverse up parent directories for additional build notes') do |p|
|
data/lib/howzit/buildnote.rb
CHANGED
@@ -89,7 +89,7 @@ module Howzit
|
|
89
89
|
# Create a buildnotes skeleton
|
90
90
|
def create_note
|
91
91
|
trap('SIGINT') do
|
92
|
-
|
92
|
+
Howzit.console.info "\nCanceled"
|
93
93
|
exit!
|
94
94
|
end
|
95
95
|
default = !$stdout.isatty || Howzit.options[:default]
|
@@ -269,8 +269,8 @@ module Howzit
|
|
269
269
|
required = t_meta['required'].strip.split(/\s*,\s*/)
|
270
270
|
required.each do |req|
|
271
271
|
unless @metadata.keys.include?(req.downcase)
|
272
|
-
|
273
|
-
|
272
|
+
Howzit.console.error %({xr}ERROR: Missing required metadata key from template '{bw}#{File.basename(template, '.md')}{xr}'{x}).c
|
273
|
+
Howzit.console.error %({xr}Please define {by}#{req.downcase}{xr} in build notes{x}).c
|
274
274
|
Process.exit 1
|
275
275
|
end
|
276
276
|
end
|
data/lib/howzit/config.rb
CHANGED
@@ -91,12 +91,12 @@ module Howzit
|
|
91
91
|
|
92
92
|
def create_config(d)
|
93
93
|
unless File.directory?(config_dir)
|
94
|
-
|
94
|
+
Howzit.console.info "Creating config directory at #{config_dir}"
|
95
95
|
FileUtils.mkdir_p(config_dir)
|
96
96
|
end
|
97
97
|
|
98
98
|
unless File.exist?(config_file)
|
99
|
-
|
99
|
+
Howzit.console.info "Writing fresh config file to #{config_file}"
|
100
100
|
write_config(d)
|
101
101
|
end
|
102
102
|
config_file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
LOG_LEVELS = {
|
4
|
+
debug: 0,
|
5
|
+
info: 1,
|
6
|
+
warn: 2,
|
7
|
+
error: 3
|
8
|
+
}.deep_freeze
|
9
|
+
|
10
|
+
module Howzit
|
11
|
+
# Console logging
|
12
|
+
class ConsoleLogger
|
13
|
+
attr_accessor :log_level
|
14
|
+
|
15
|
+
def initialize(level = nil)
|
16
|
+
@log_level = level || Howzit.options[:log_level]
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset_level
|
20
|
+
@log_level = Howzit.options[:log_level]
|
21
|
+
end
|
22
|
+
|
23
|
+
def write(msg, level = :info)
|
24
|
+
$stderr.puts msg if LOG_LEVELS[level] >= @log_level
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug(msg)
|
28
|
+
write msg, :debug
|
29
|
+
end
|
30
|
+
|
31
|
+
def info(msg)
|
32
|
+
write msg, :info
|
33
|
+
end
|
34
|
+
|
35
|
+
def warn(msg)
|
36
|
+
write msg, :warn
|
37
|
+
end
|
38
|
+
|
39
|
+
def error(msg)
|
40
|
+
write msg, :error
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/howzit/prompt.rb
CHANGED
data/lib/howzit/task.rb
CHANGED
data/lib/howzit/topic.rb
CHANGED
@@ -42,7 +42,7 @@ module Howzit
|
|
42
42
|
end
|
43
43
|
|
44
44
|
if task.type == :block
|
45
|
-
|
45
|
+
Howzit.console.info "{bg}Running block {bw}#{title}{x}".c if Howzit.options[:log_level] < 2
|
46
46
|
block = task.action
|
47
47
|
script = Tempfile.new('howzit_script')
|
48
48
|
begin
|
@@ -81,7 +81,7 @@ module Howzit
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
else
|
84
|
-
warn "{r}--run: No {br}@directive{xr} found in {bw}#{@title}{x}".c
|
84
|
+
Howzit.console.warn "{r}--run: No {br}@directive{xr} found in {bw}#{@title}{x}".c
|
85
85
|
end
|
86
86
|
output.push("{bm}Ran #{tasks} #{tasks == 1 ? 'task' : 'tasks'}{x}".c) if Howzit.options[:log_level] < 2 && !nested
|
87
87
|
|
@@ -95,21 +95,21 @@ module Howzit
|
|
95
95
|
out = "{bg}Copying {bw}#{string}".c
|
96
96
|
case os
|
97
97
|
when /darwin.*/i
|
98
|
-
|
98
|
+
$stderr.puts "#{out} (macOS){x}".c if Howzit.options[:log_level].zero?
|
99
99
|
`echo #{Shellwords.escape(string)}'\\c'|pbcopy`
|
100
100
|
when /mingw|mswin/i
|
101
|
-
|
101
|
+
$stderr.puts "#{out} (Windows){x}".c if Howzit.options[:log_level].zero?
|
102
102
|
`echo #{Shellwords.escape(string)} | clip`
|
103
103
|
else
|
104
104
|
if 'xsel'.available?
|
105
|
-
|
105
|
+
$stderr.puts "#{out} (Linux, xsel){x}".c if Howzit.options[:log_level].zero?
|
106
106
|
`echo #{Shellwords.escape(string)}'\\c'|xsel -i`
|
107
107
|
elsif 'xclip'.available?
|
108
|
-
|
108
|
+
$stderr.puts "#{out} (Linux, xclip){x}".c if Howzit.options[:log_level].zero?
|
109
109
|
`echo #{Shellwords.escape(string)}'\\c'|xclip -i`
|
110
110
|
else
|
111
|
-
|
112
|
-
|
111
|
+
$stderr.puts out if Howzit.options[:log_level].zero?
|
112
|
+
$stderr.puts 'Unable to determine executable for clipboard.'
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -119,18 +119,18 @@ module Howzit
|
|
119
119
|
out = "{bg}Opening {bw}#{command}".c
|
120
120
|
case os
|
121
121
|
when /darwin.*/i
|
122
|
-
|
122
|
+
Howzit.console.debug "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
|
123
123
|
`open #{Shellwords.escape(command)}`
|
124
124
|
when /mingw|mswin/i
|
125
|
-
|
125
|
+
Howzit.console.debug "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
|
126
126
|
`start #{Shellwords.escape(command)}`
|
127
127
|
else
|
128
128
|
if 'xdg-open'.available?
|
129
|
-
|
129
|
+
Howzit.console.debug "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
|
130
130
|
`xdg-open #{Shellwords.escape(command)}`
|
131
131
|
else
|
132
|
-
|
133
|
-
|
132
|
+
Howzit.console.debug out if Howzit.options[:log_level] < 2
|
133
|
+
Howzit.console.debug 'Unable to determine executable for `open`.'
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
data/lib/howzit/util.rb
CHANGED
@@ -40,7 +40,7 @@ module Howzit
|
|
40
40
|
if hl.available?
|
41
41
|
Howzit.options[:highlighter]
|
42
42
|
else
|
43
|
-
|
43
|
+
Howzit.console.error Color.template("{Rw}Error:{xbw} Specified highlighter (#{Howzit.options[:highlighter]}) not found, switching to auto")
|
44
44
|
Howzit.options[:highlighter] = 'auto'
|
45
45
|
which_highlighter
|
46
46
|
end
|
@@ -78,7 +78,7 @@ module Howzit
|
|
78
78
|
if pg.available?
|
79
79
|
Howzit.options[:pager]
|
80
80
|
else
|
81
|
-
|
81
|
+
Howzit.console.error Color.template("{Rw}Error:{xbw} Specified pager (#{Howzit.options[:pager]}) not found, switching to auto")
|
82
82
|
Howzit.options[:pager] = 'auto'
|
83
83
|
which_pager
|
84
84
|
end
|
@@ -104,7 +104,7 @@ module Howzit
|
|
104
104
|
begin
|
105
105
|
exec(pager)
|
106
106
|
rescue SystemCallError => e
|
107
|
-
|
107
|
+
Howzit.console.error(e)
|
108
108
|
exit 1
|
109
109
|
end
|
110
110
|
end
|
data/lib/howzit/version.rb
CHANGED
data/lib/howzit.rb
CHANGED
@@ -5,8 +5,9 @@ require_relative 'howzit/prompt'
|
|
5
5
|
require_relative 'howzit/colors'
|
6
6
|
require_relative 'howzit/stringutils'
|
7
7
|
|
8
|
-
require_relative 'howzit/util'
|
9
8
|
require_relative 'howzit/hash'
|
9
|
+
require_relative 'howzit/console_logger'
|
10
|
+
require_relative 'howzit/util'
|
10
11
|
require_relative 'howzit/config'
|
11
12
|
require_relative 'howzit/task'
|
12
13
|
require_relative 'howzit/topic'
|
@@ -52,5 +53,9 @@ module Howzit
|
|
52
53
|
def buildnote
|
53
54
|
@buildnote ||= BuildNote.new
|
54
55
|
end
|
56
|
+
|
57
|
+
def console
|
58
|
+
@console ||= Howzit::ConsoleLogger.new(options[:log_level])
|
59
|
+
end
|
55
60
|
end
|
56
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: howzit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/howzit/buildnotes.rb
|
273
273
|
- lib/howzit/colors.rb
|
274
274
|
- lib/howzit/config.rb
|
275
|
+
- lib/howzit/console_logger.rb
|
275
276
|
- lib/howzit/hash.rb
|
276
277
|
- lib/howzit/prompt.rb
|
277
278
|
- lib/howzit/stringutils.rb
|