howzit 2.0.28 → 2.0.31

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: c2a724cc90c349de14afa896512a32d69bcf2fa44575f69e74b0a6f96d615ebb
4
- data.tar.gz: 73c54a8893fa66784575235d329ad698da6e7a34a2741e09d2d93149b118f68a
3
+ metadata.gz: 26dd07092f365cd21cb4d077f0bc50fca533af0a887254e3086aa9151bb6a45a
4
+ data.tar.gz: e015fc62c9540593afd17f8b134c1e0bedbd7ee14424ec02f9d8a7de419219c5
5
5
  SHA512:
6
- metadata.gz: 4d4c9e0c7e5c78f10479cea93dffa09fdf768d335210897feb127f849040bced7a05924a60f6621173ececb1fde116fe5a3ecc79270767c12718b1a1f9742281
7
- data.tar.gz: ff2c18f91883cf4f3b6035b8b304a23575381fd1b9a74333781db8ac000b13d03eb43969bb80d964e3dafeec3556a2152392b2eb074a34561981753233e1fc9e
6
+ metadata.gz: 549a57df5cd0e0760ba579dea70c82d08db6cc743b5bcf3e659058534f01dfd2536ebf1fd0f3f47dac2e9275ed82ebef8353c630c961424797dc281931a4fc22
7
+ data.tar.gz: f9fe0d54b25137ec1d89dfcd5ead0ee9814dd5b74af0a4797743c4e1f28e793aee4d018bfc1d1774470f5d7979dd9866aea80539a0bccc462f0fc0e53e413f77
data/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ### 2.0.31
2
+
3
+ 2022-08-31 07:17
4
+
5
+ #### FIXED
6
+
7
+ - Color template formatting of task output
8
+
9
+ ### 2.0.30
10
+
11
+ 2022-08-31 07:15
12
+
13
+ #### FIXED
14
+
15
+ - Formatting of --help and --version commands
16
+
17
+ ### 2.0.29
18
+
19
+ 2022-08-30 04:20
20
+
21
+ #### NEW
22
+
23
+ - --yes flag will answer yes to all prompts when executing
24
+ - --force flag will continue executing directives after an error
25
+
26
+ #### IMPROVED
27
+
28
+ - A non-zero exit status on a run directive will stop processing additional directives
29
+ - A little extra output formatting, more descriptive results logging
30
+
1
31
  ### 2.0.28
2
32
 
3
33
  2022-08-29 18:42
data/bin/howzit CHANGED
@@ -11,7 +11,7 @@ args = parts[0] ? Shellwords.shellsplit(parts[0]) : []
11
11
  Howzit.arguments = parts[1] ? Shellwords.shellsplit(parts[1]) : []
12
12
 
13
13
  OptionParser.new do |opts|
14
- opts.banner = "Usage: #{__FILE__} [OPTIONS] [TOPIC]"
14
+ opts.banner = "Usage: #{File.basename(__FILE__)} [OPTIONS] [TOPIC]"
15
15
  opts.separator ''
16
16
  opts.separator 'Show build notes for the current project (buildnotes.md).
17
17
  Include a topic name to see just that topic, or no argument to display all.'
@@ -20,14 +20,16 @@ OptionParser.new do |opts|
20
20
 
21
21
  opts.separator " Behavior:\n\n" #=================================================================== BEHAVIOR
22
22
 
23
- opts.on('--ask', 'Request confirmation for all tasks when running a topic') do
24
- Howzit.options[:ask] = true
25
- end
23
+ opts.on('--ask', 'Request confirmation for all tasks when running a topic') { Howzit.options[:ask] = true }
26
24
 
27
25
  opts.on('--default', 'Answer all prompts with default response') do
26
+ raise '--default cannot be used with --yes' if Howzit.options[:yes]
27
+
28
28
  Howzit.options[:default] = true
29
29
  end
30
30
 
31
+ opts.on('-f', '--force', 'Continue executing after an error') { Howzit.options[:force] = true }
32
+
31
33
  opts.on('-m', '--matching TYPE', MATCHING_OPTIONS,
32
34
  'Topics matching type', "(#{MATCHING_OPTIONS.join(', ')})") do |c|
33
35
  Howzit.options[:matching] = c
@@ -42,6 +44,12 @@ OptionParser.new do |opts|
42
44
  Howzit.options[:include_upstream] = p
43
45
  end
44
46
 
47
+ opts.on('-y', '--yes', 'Answer yes to all prompts') do
48
+ raise '--default cannot be used with --yes' if Howzit.options[:default]
49
+
50
+ Howzit.options[:yes] = true
51
+ end
52
+
45
53
  opts.separator "\n Listing:\n\n" #=================================================================== LISTING
46
54
 
47
55
  opts.on('-L', '--list-completions', 'List topics (completion-compatible)') do
@@ -225,7 +233,7 @@ OptionParser.new do |opts|
225
233
  end
226
234
 
227
235
  opts.on('-v', '--version', 'Display version number') do
228
- puts "how v#{Howzit::VERSION}"
236
+ puts "#{File.basename(__FILE__)} v#{Howzit::VERSION}"
229
237
  Process.exit 0
230
238
  end
231
239
  end.parse!(args)
data/lib/howzit/colors.rb CHANGED
@@ -227,7 +227,7 @@ module Howzit
227
227
  def template(input)
228
228
  input = input.join(' ') if input.is_a? Array
229
229
  fmt = input.gsub(/%/, '%%')
230
- fmt = fmt.gsub(/\{(\w+)\}/) do
230
+ fmt = fmt.gsub(/(?<!\\u)\{(\w+)\}/i) do
231
231
  Regexp.last_match(1).split('').map { |c| "%<#{c}>s" }.join('')
232
232
  end
233
233
 
data/lib/howzit/config.rb CHANGED
@@ -91,6 +91,7 @@ module Howzit
91
91
  choose: false,
92
92
  default: false,
93
93
  for_topic: nil,
94
+ force: false,
94
95
  grep: nil,
95
96
  list_runnable: false,
96
97
  list_runnable_titles: false,
@@ -99,7 +100,8 @@ module Howzit
99
100
  quiet: false,
100
101
  run: false,
101
102
  title_only: false,
102
- verbose: false
103
+ verbose: false,
104
+ yes: false
103
105
  }
104
106
 
105
107
  config = load_config
data/lib/howzit/prompt.rb CHANGED
@@ -18,6 +18,8 @@ module Howzit
18
18
  def yn(prompt, default: true)
19
19
  return default unless $stdout.isatty
20
20
 
21
+ return true if Howzit.options[:yes]
22
+
21
23
  return default if Howzit.options[:default]
22
24
 
23
25
  tty_state = `stty -g`
data/lib/howzit/task.rb CHANGED
@@ -19,6 +19,9 @@ module Howzit
19
19
  ## @option attributes :action [String] task action
20
20
  ## @option attributes :parent [String] title of nested (included) topic origin
21
21
  def initialize(attributes, optional: false, default: true)
22
+ @prefix = "{bw}\u{25B7}\u{25B7} {x}"
23
+ # arrow = "{bw}\u{279F}{x}"
24
+
22
25
  @type = attributes[:type] || :run
23
26
  @title = attributes[:title] || nil
24
27
  @action = attributes[:action].render_arguments || nil
@@ -49,7 +52,7 @@ module Howzit
49
52
  ## Execute a block type
50
53
  ##
51
54
  def run_block
52
- Howzit.console.info "{bg}Running block {bw}#{@title}{x}".c if Howzit.options[:log_level] < 2
55
+ Howzit.console.info "#{@prefix}{bg}Running block {bw}#{@title}{x}".c if Howzit.options[:log_level] < 2
53
56
  block = @action
54
57
  script = Tempfile.new('howzit_script')
55
58
  begin
@@ -75,7 +78,7 @@ module Howzit
75
78
  matches = Howzit.buildnote.find_topic(@action)
76
79
  raise "Topic not found: #{@action}" if matches.empty?
77
80
 
78
- Howzit.console.info("{by}Running tasks from {bw}#{matches[0].title}{x}".c)
81
+ Howzit.console.info("#{@prefix}{by}Running tasks from {bw}#{matches[0].title}{x}".c)
79
82
  output.concat(matches[0].run(nested: true))
80
83
  Howzit.console.info("{by}End include: #{matches[0].tasks.count} tasks{x}".c)
81
84
  [output, matches[0].tasks.count]
@@ -86,7 +89,7 @@ module Howzit
86
89
  ##
87
90
  def run_run
88
91
  title = Howzit.options[:show_all_code] ? @action : @title
89
- Howzit.console.info("{bg}Running {bw}#{title}{x}".c)
92
+ Howzit.console.info("#{@prefix}{bg}Running {bw}#{title}{x}".c)
90
93
  return system(@action)
91
94
  end
92
95
 
@@ -95,7 +98,7 @@ module Howzit
95
98
  ##
96
99
  def run_copy
97
100
  title = Howzit.options[:show_all_code] ? @action : @title
98
- Howzit.console.info("{bg}Copied {bw}#{title}{bg} to clipboard{x}".c)
101
+ Howzit.console.info("#{@prefix}{bg}Copied {bw}#{title}{bg} to clipboard{x}".c)
99
102
  Util.os_copy(@action)
100
103
  return true
101
104
  end
data/lib/howzit/topic.rb CHANGED
@@ -7,7 +7,7 @@ module Howzit
7
7
 
8
8
  attr_accessor :content
9
9
 
10
- attr_reader :title, :tasks, :prereqs, :postreqs
10
+ attr_reader :title, :tasks, :prereqs, :postreqs, :results
11
11
 
12
12
  ##
13
13
  ## Initialize a topic object
@@ -21,6 +21,7 @@ module Howzit
21
21
  @parent = nil
22
22
  @nest_level = 0
23
23
  @tasks = gather_tasks
24
+ @results = { total: 0, success: 0, errors: 0, message: ''.c }
24
25
  end
25
26
 
26
27
  ##
@@ -35,7 +36,7 @@ module Howzit
35
36
  # Handle run command, execute directives in topic
36
37
  def run(nested: false)
37
38
  output = []
38
- tasks = 0
39
+
39
40
  cols = begin
40
41
  TTY::Screen.columns > 60 ? 60 : TTY::Screen.columns
41
42
  rescue StandardError
@@ -66,17 +67,33 @@ module Howzit
66
67
  run_output, total, success = task.run
67
68
 
68
69
  output.concat(run_output)
69
- tasks += total
70
+ @results[:total] += total
71
+
72
+ if success
73
+ @results[:success] += total
74
+ else
75
+ Howzit.console.warn %({bw}\u{2297} {br}Error running task {bw}"#{task.title}"{x}).c
76
+
77
+ @results[:errors] += total
70
78
 
71
- unless success
72
- Howzit.console.warn '{br}Error running task{bw} - non-zero exit, ending processing{x}'.c
73
- break
79
+ break unless Howzit.options[:force]
74
80
  end
75
81
  end
82
+
83
+ total = "{bw}#{@results[:total]}{by} #{@results[:total] == 1 ? 'task' : 'tasks'}".c
84
+ errors = "{bw}#{@results[:errors]}{by} #{@results[:errors] == 1 ? 'error' : 'errors'}".c
85
+ @results[:message] += if @results[:errors].zero?
86
+ "{bg}\u{2713} {by}Ran #{total}{x}".c
87
+ elsif Howzit.options[:force]
88
+ "{br}\u{2715} {by}Completed #{total} with #{errors}{x}".c
89
+ else
90
+ "{br}\u{2715} {by}Ran #{total}, terminated due to error{x}".c
91
+ end
76
92
  else
77
93
  Howzit.console.warn "{r}--run: No {br}@directive{xr} found in {bw}#{@title}{x}".c
78
94
  end
79
- output.push("{bm}Ran #{tasks} #{tasks == 1 ? 'task' : 'tasks'}{x}".c) if Howzit.options[:log_level] < 2 && !nested
95
+
96
+ output.push(@results[:message]) if Howzit.options[:log_level] < 2 && !nested
80
97
 
81
98
  puts TTY::Box.frame("{bw}#{@postreqs.join("\n\n").wrap(cols - 4)}{x}".c, width: cols) unless @postreqs.empty?
82
99
 
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.0.28'
6
+ VERSION = '2.0.31'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: howzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.28
4
+ version: 2.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-29 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler