cmd-utils 1.2.0 → 1.3.0

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
  SHA1:
3
- metadata.gz: 19937d5ab0376abd84254c084edaec772b501d42
4
- data.tar.gz: 130e9b5ec4997a36db8c4e46503650ca55f53288
3
+ metadata.gz: fce02fbcbd166ba24d890457e77eb21414efabda
4
+ data.tar.gz: 208ac2a33a259f801c17e50e5e864c0b568d36fe
5
5
  SHA512:
6
- metadata.gz: a1fe074ab79e0f4e541f3ab7c3325ad60e836e40ff8895168591131ea1391433347eb5f3dbb1e3d9a25eb053643105c48ccd2f66e7303fbd91e75da28c87c9ac
7
- data.tar.gz: 9f359fed8970713e8a5ce436ce031a9b5d67d0ac80383691a89daa195d275c001f84f573e039664f776a8f2dcfe7e4ec539e0e9a897c60291ab4268bd14d7d0b
6
+ metadata.gz: 5c40c5d2aca9229db112702ddfceef3793c3879a02e4ce55e3519ee7c3b464d54c0bb0925ee864231c15ad853664ba0f27e97ca373cb51b1ce27029b6de6f4c4
7
+ data.tar.gz: 14caa6507a0cb6343d496d6f77ad3ebc6662ee18002d92b6e6acd13ab4d6113ac867553e283b0a67eee1d9e6efb0798c02a9776ea230363760ca07245c82c50a
data/README.md CHANGED
@@ -54,49 +54,57 @@ Talk:
54
54
  talk msg - print msg on STDERR unless $quiet
55
55
  talk { msg }
56
56
  talkf fmt, args ..
57
- talkf(fmt) { args .. }
57
+ talkf(fmt) {[args,..]}
58
58
 
59
59
  Debug talk:
60
60
 
61
61
  dtalk msg - print msg on STDERR if $debug
62
62
  dtalk { msg }
63
63
  dtalkf fmt, args ..
64
- dtalkf(fmt) { args .. }
64
+ dtalkf(fmt) {[args,..]}
65
65
 
66
66
  Quiet talk:
67
67
 
68
68
  qtalk msg - print msg on STDERR if $quiet
69
69
  qtalk { msg }
70
70
  qtalkf fmt, args ..
71
- qtalkf(fmt) { args .. }
71
+ qtalkf(fmt) {[args,..]}
72
72
 
73
73
  Verbose talk:
74
74
 
75
75
  vtalk msg - print msg on STDERR if $verbose
76
76
  vtalk { msg }
77
77
  vtalkf fmt, args ..
78
- vtalkf(fmt) { args .. }
78
+ vtalkf(fmt) {[args,..]}
79
79
 
80
80
  No-run talk:
81
81
 
82
82
  nrtalk msg - print msg on STDERR if $norun || $verbose
83
83
  nrtalk { msg }
84
84
  nrtalkf fmt, args ..
85
- nrtalkf(fmt) { args .. }
85
+ nrtalkf(fmt) {[args, ..]}
86
86
 
87
87
  Non-verbose talk:
88
88
 
89
89
  nvtalk msg - print msg on STDERR unless $verbose
90
90
  nvtalk { msg }
91
91
  nvtalkf fmt, args ..
92
- nvtalkf(fmt) { args .. }
92
+ nvtalkf(fmt) {[args ..]}
93
+
94
+ No-run or verbose talk:
95
+
96
+ nvrtalk msg - print msg on STDERR prefixed with '(norun) ' or '>> '
97
+ nvrtalk { msg }
98
+ nvrtalkf fmt, args ..
99
+ nvrtalkf(fmt) {[args, ..]}
100
+ nvrtalkf {[ fmt, args, ...]}
93
101
 
94
102
  Error output:
95
103
 
96
- error [code,] msg - print msg on STDERR, exit with CODE [default:1]
97
- error { [ [code,] msg ] }
98
- errorf [code,] fmt, args ..
99
- errorf { [ [code,] fmt, args .. ] }
104
+ error [code,] msg - print msg on STDERR, exit with CODE [default:1]
105
+ error {[[code,] msg]}
106
+ errorf [code,] fmt, args ..
107
+ errorf {[[code,] fmt, args ..]}
100
108
 
101
109
  The `error` routine take an optional numeric first argument which is used to
102
110
  set the exit code. If not given, the exit code is 1.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
data/cmd-utils.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: cmd-utils 1.2.0 ruby lib
5
+ # stub: cmd-utils 1.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cmd-utils"
9
- s.version = "1.2.0"
9
+ s.version = "1.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
data/lib/run-utils.rb CHANGED
@@ -67,7 +67,7 @@ end
67
67
  def cmd_run *args
68
68
  args = _msgargs(args, block_given?) { yield }
69
69
  if $norun
70
- nrtalk(args.first)
70
+ nrvtalk(args.first)
71
71
  elsif args.size > 0
72
72
  safe_run(*args)
73
73
  end
data/lib/talk-utils.rb CHANGED
@@ -53,6 +53,7 @@ end
53
53
  # dtalk { msg }
54
54
  # dtalkf fmt, args ..
55
55
  # dtalkf fmt { [ args .. ] }
56
+ # dtalkf { [ fmt, args .. ] }
56
57
 
57
58
  def dtalk *args
58
59
  if $debug && (args.size > 0 || block_given?)
@@ -75,6 +76,7 @@ end
75
76
  # qtalk { msg }
76
77
  # qtalkf fmt, args ..
77
78
  # qtalkf fmt { [ args .. ] }
79
+ # qtalkf { [ fmt, args, ... ] }
78
80
 
79
81
  def qtalk *args
80
82
  if $quiet && (args.size > 0 || block_given?)
@@ -97,6 +99,7 @@ end
97
99
  # vtalk { msg }
98
100
  # vtalkf fmt, args ..
99
101
  # vtalkf fmt { args .. }
102
+ # vtalkf { [ fmt, args ... ] }
100
103
 
101
104
  def vtalk *args
102
105
  if $verbose && (args.size > 0 || block_given?)
@@ -139,22 +142,61 @@ end
139
142
  # nrtalk { msg }
140
143
  # nrtalkf fmt, msg
141
144
  # nrtalkf fmt { msg }
145
+ # nrtalkf { [ fmt, msg ] }
142
146
 
143
147
  def nrtalk *args
144
148
  if $norun && (args.size > 0 || block_given?)
145
- newargs = _msgargs(args, block_given?) { yield }
146
- newargs[0] = '(norun) ' + newargs[0] unless newargs.size == 0 || newargs[0].nil? || newargs[0].include?('(norun)')
147
- $stderr.puts(*newargs)
149
+ $stderr.puts(*_prefix_arg0(_msgargs(args, block_given?){yield},'(norun) '))
148
150
  end
149
151
  end
150
152
 
151
153
  def nrtalkf *args
152
154
  if $norun && (args.size > 0 || block_given?)
153
- newargs = _fmtargs(args, block_given?) { yield }
154
- newargs[0] = '(norun) ' + newargs[0] unless newargs.size == 0 || newargs[0].nil? || newargs[0].include?('(norun)')
155
- $stderr.printf(*newargs)
155
+ $stderr.printf(*_prefix_arg0(_fmtargs(args, block_given?){yield},'(norun) '))
156
156
  end
157
157
  end
158
158
 
159
+ # nrvtalk -- "no run" or verbose talk
160
+ #
161
+ # Print msg, possibly prefixed with "(norun)" or ">>" (verbose), on STDERR only
162
+ # if $norun or $verbose are set.
163
+ #
164
+ # :call-seq:
165
+ # nrvtalk msg
166
+ # nrvtalk { msg }
167
+ # nrvtalkf fmt, args, ..
168
+ # nrvtalkf fmt { [ args, ..] }
169
+ # nrvtalkf { [ fmt, args .. ] }
170
+
171
+ def nrvtalk *args
172
+ _args = _msgargs(args, block_given?) { yield }
173
+ if $norun && _args.size > 0
174
+ nrtalk(*_args)
175
+ elsif $verbose && _args.size > 0
176
+ vtalk(*_prefix_arg0(_args, '>> '))
177
+ end
178
+ end
179
+
180
+ def nrvtalkf *args
181
+ _args = _fmtargs(args, block_given?) { yield }
182
+ if $norun && _args.size > 0
183
+ nrtalkf(*_args)
184
+ elsif $verbose && _args.size > 0
185
+ vtalkf(*_prefix_arg0(_args, '>> '))
186
+ end
187
+ end
188
+
189
+ # _prefix_arg0( args, prefix )
190
+ #
191
+ # Prefix args[0] if the prefix is not already there, and if the args[0] value is
192
+ # not nill.
193
+
194
+ def _prefix_arg0(args, prefix)
195
+ if args.size > 0 && !args[0].nil? && !args[0].include?(prefix)
196
+ args[0] = prefix + args[0]
197
+ end
198
+ args
199
+ end
200
+
159
201
  # end of talk-utils.sh
160
202
  # vim: set ai sw=2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan K. Stebbens