rexe 1.0.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +9 -4
- data/exe/rexe +94 -76
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab00704245578c9561f0505ecf8bd7e89726a1c8c6df3ffd6a7ac42cd47cde9
|
4
|
+
data.tar.gz: f9a016b6c972c9960f6e42042ad5531b095fb69ccee8409b770d3da52c40f3d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34399b21ef6425c9107f42fe5809c4d3e4b98e5a1e88680dfdfb074f0b8c5b3f5e94c2b83d31299a948d2b54b873e41580d0cb1d4f1c57de2f10a29bce3a4da6
|
7
|
+
data.tar.gz: 7956d7b7b7f0ee154f345c9fd375e86913d9abf8b38f0e2d0d69cd5b2354ec6db9675bb3b425f077f0b4b1f572970c177daa64ce299a3293cd86dd45da219eee
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
## rexe -- Ruby Command Line Executor/Filter
|
2
2
|
|
3
|
+
### 1.3.0
|
4
|
+
|
5
|
+
* Document --project-url option.
|
6
|
+
* Add undocumented option --open-project to output Github project URL.
|
7
|
+
* Simplify test as per @davetron5000's array based approach.
|
8
|
+
* Fix context do/end in test code.
|
9
|
+
* Froze strings: VERSION, PROJECT_URL, help_text.
|
10
|
+
|
11
|
+
|
12
|
+
### 1.2.0
|
13
|
+
|
14
|
+
* Add --project-url option to output project URL on Github, then exit
|
15
|
+
|
16
|
+
|
17
|
+
### 1.1.0
|
18
|
+
|
19
|
+
* Enable specifying different output formats for tty and block devices. (#4)
|
20
|
+
* Outputs exception text on error instead of just exception class.
|
21
|
+
|
3
22
|
|
4
23
|
### 1.0.3
|
5
24
|
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ Rexe is at https://github.com/keithrbennett/rexe and can be installed with `gem
|
|
73
73
|
Here is rexe's help text as of the time of this writing:
|
74
74
|
|
75
75
|
```
|
76
|
-
rexe -- Ruby Command Line Executor/Filter -- v1.0
|
76
|
+
rexe -- Ruby Command Line Executor/Filter -- v1.3.0 -- https://github.com/keithrbennett/rexe
|
77
77
|
|
78
78
|
Executes Ruby code on the command line,
|
79
79
|
optionally automating management of standard input and standard output,
|
@@ -115,6 +115,8 @@ Options:
|
|
115
115
|
-op Puts
|
116
116
|
-os to_s
|
117
117
|
-oy YAML
|
118
|
+
If 2 letters are provided, 1st is for tty devices, 2nd for block
|
119
|
+
--project-url Outputs project URL on Github, then exits
|
118
120
|
-r, --require REQUIRE(S) Gems and built-in libraries to require, comma separated;
|
119
121
|
! to clear all, or precede a name with '-' to remove
|
120
122
|
-v, --version Prints version and exits
|
@@ -263,12 +265,13 @@ If you would like to append this informational output to a file(e.g. `rexe.log`)
|
|
263
265
|
Rexe tries to make it simple and convenient for you to handle standard input, and in different ways. Here is the help text relating to input modes:
|
264
266
|
|
265
267
|
```
|
266
|
-
-m, --input_mode MODE Input preprocessing mode (determines what `self` will be)
|
268
|
+
-m, --input_mode MODE Input preprocessing mode (determines what `self` will be)
|
269
|
+
defaults to -mn (none)
|
267
270
|
-ml line; each line is ingested as a separate string
|
268
271
|
-me enumerator (each_line on STDIN or File)
|
269
272
|
-mb big string; all lines combined into one string
|
270
|
-
-mn none (default); no input preprocessing;
|
271
|
-
self is an Object.new
|
273
|
+
-mn none (default); no input preprocessing;
|
274
|
+
self is an Object.new
|
272
275
|
```
|
273
276
|
|
274
277
|
The first three are _filter_ modes; they make standard input available to your code as `self`.
|
@@ -369,6 +372,8 @@ All formats will implicitly `require` anything needed to accomplish their task (
|
|
369
372
|
|
370
373
|
The default is `-on` to produce no output at all (unless explicitly coded to do so). If you prefer a different default such as `-op` for _puts_ mode, you can specify that in your `REXE_OPTIONS` environment variable.
|
371
374
|
|
375
|
+
If two letters are provided, the first will be used for tty devices (e.g. the terminal when not redirected or piped), and the second for block devices (e.g. when redirected or piped to another process).
|
376
|
+
|
372
377
|
You may wonder why these formats are provided, given that their functionality could be included in the custom code instead. Here's why:
|
373
378
|
|
374
379
|
* The savings in command line length goes a long way to making these commands more readable and feasible.
|
data/exe/rexe
CHANGED
@@ -12,9 +12,9 @@ require 'shellwords'
|
|
12
12
|
|
13
13
|
class Rexe
|
14
14
|
|
15
|
-
VERSION = '1.0.
|
15
|
+
VERSION = '1.3.0'.freeze
|
16
16
|
|
17
|
-
PROJECT_URL = 'https://github.com/keithrbennett/rexe'
|
17
|
+
PROJECT_URL = 'https://github.com/keithrbennett/rexe'.freeze
|
18
18
|
|
19
19
|
|
20
20
|
module Helpers
|
@@ -25,7 +25,7 @@ class Rexe
|
|
25
25
|
yield
|
26
26
|
rescue Exception => e
|
27
27
|
unless e.class == SystemExit
|
28
|
-
$stderr.puts('rexe: ' << e.
|
28
|
+
$stderr.puts('rexe: ' << e.to_s)
|
29
29
|
$stderr.puts("Use the -h option to get help.")
|
30
30
|
exit(-1)
|
31
31
|
end
|
@@ -40,6 +40,8 @@ class Rexe
|
|
40
40
|
:input_mode,
|
41
41
|
:loads,
|
42
42
|
:output_format,
|
43
|
+
:output_format_tty,
|
44
|
+
:output_format_block,
|
43
45
|
:requires,
|
44
46
|
:log_format,
|
45
47
|
:noop)
|
@@ -53,13 +55,15 @@ class Rexe
|
|
53
55
|
|
54
56
|
def clear
|
55
57
|
self.input_filespec = nil
|
56
|
-
self.input_format
|
57
|
-
self.input_mode
|
58
|
-
self.output_format
|
59
|
-
self.
|
60
|
-
self.
|
61
|
-
self.
|
62
|
-
self.
|
58
|
+
self.input_format = :none
|
59
|
+
self.input_mode = :none
|
60
|
+
self.output_format = :none
|
61
|
+
self.output_format_tty = :none
|
62
|
+
self.output_format_block = :none
|
63
|
+
self.loads = []
|
64
|
+
self.requires = []
|
65
|
+
self.log_format = :none
|
66
|
+
self.noop = false
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -173,69 +177,77 @@ class Rexe
|
|
173
177
|
|
174
178
|
|
175
179
|
private def help_text
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
180
|
+
unless @help_text
|
181
|
+
@help_text ||= <<~HEREDOC
|
182
|
+
|
183
|
+
rexe -- Ruby Command Line Executor/Filter -- v#{VERSION} -- #{PROJECT_URL}
|
184
|
+
|
185
|
+
Executes Ruby code on the command line,
|
186
|
+
optionally automating management of standard input and standard output,
|
187
|
+
and optionally parsing input and formatting output with YAML, JSON, etc.
|
188
|
+
|
189
|
+
rexe [options] [Ruby source code]
|
190
|
+
|
191
|
+
Options:
|
192
|
+
|
193
|
+
-c --clear_options Clear all previous command line options specified up to now
|
194
|
+
-f --input_file Use this file instead of stdin for preprocessed input;
|
195
|
+
if filespec has a YAML and JSON file extension,
|
196
|
+
sets input format accordingly and sets input mode to -mb
|
197
|
+
-g --log_format FORMAT Log format, logs to stderr, defaults to -gn (none)
|
198
|
+
(see -o for format options)
|
199
|
+
-h, --help Print help and exit
|
200
|
+
-i, --input_format FORMAT Input format, defaults to -in (None)
|
201
|
+
-ij JSON
|
202
|
+
-im Marshal
|
203
|
+
-in None (default)
|
204
|
+
-iy YAML
|
205
|
+
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated;
|
206
|
+
! to clear all, or precede a name with '-' to remove
|
207
|
+
-m, --input_mode MODE Input preprocessing mode (determines what `self` will be)
|
208
|
+
defaults to -mn (none)
|
209
|
+
-ml line; each line is ingested as a separate string
|
210
|
+
-me enumerator (each_line on STDIN or File)
|
211
|
+
-mb big string; all lines combined into one string
|
212
|
+
-mn none (default); no input preprocessing;
|
213
|
+
self is an Object.new
|
214
|
+
-n, --[no-]noop Do not execute the code (useful with -g);
|
215
|
+
For true: yes, true, y, +; for false: no, false, n
|
216
|
+
-o, --output_format FORMAT Output format, defaults to -on (no output):
|
217
|
+
-oi Inspect
|
218
|
+
-oj JSON
|
219
|
+
-oJ Pretty JSON
|
220
|
+
-om Marshal
|
221
|
+
-on No Output (default)
|
222
|
+
-op Puts
|
223
|
+
-os to_s
|
224
|
+
-oy YAML
|
225
|
+
If 2 letters are provided, 1st is for tty devices, 2nd for block
|
226
|
+
--project-url Outputs project URL on Github, then exits
|
227
|
+
-r, --require REQUIRE(S) Gems and built-in libraries to require, comma separated;
|
228
|
+
! to clear all, or precede a name with '-' to remove
|
229
|
+
-v, --version Prints version and exits
|
230
|
+
|
231
|
+
---------------------------------------------------------------------------------------
|
232
|
+
|
233
|
+
In many cases you will need to enclose your source code in single or double quotes.
|
234
|
+
|
235
|
+
If source code is not specified, it will default to 'self',
|
236
|
+
which is most likely useful only in a filter mode (-ml, -me, -mb).
|
237
|
+
|
238
|
+
If there is a .rexerc file in your home directory, it will be run as Ruby code
|
239
|
+
before processing the input.
|
240
|
+
|
241
|
+
If there is a REXE_OPTIONS environment variable, its content will be prepended
|
242
|
+
to the command line so that you can specify options implicitly
|
243
|
+
(e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
|
237
244
|
|
238
245
|
HEREDOC
|
246
|
+
|
247
|
+
@help_text.freeze
|
248
|
+
end
|
249
|
+
|
250
|
+
@help_text
|
239
251
|
end
|
240
252
|
|
241
253
|
|
@@ -348,10 +360,11 @@ class Rexe
|
|
348
360
|
|
349
361
|
parser.on('-o', '--output_format FORMAT',
|
350
362
|
'Mode with which to format values for output (`-o` + [aijJmnpsy])') do |v|
|
351
|
-
|
352
|
-
options.
|
353
|
-
|
354
|
-
|
363
|
+
options.output_format_tty = lookups.output_formats[v[0]]
|
364
|
+
options.output_format_block = lookups.output_formats[v[-1]]
|
365
|
+
options.output_format = ($stdout.tty? ? options.output_format_tty : options.output_format_block)
|
366
|
+
if [options.output_format_tty, options.output_format_block].include?(nil)
|
367
|
+
raise("Bad output mode '#{v}'; each must be one of #{lookups.output_formats.keys}.")
|
355
368
|
end
|
356
369
|
end
|
357
370
|
|
@@ -375,12 +388,17 @@ class Rexe
|
|
375
388
|
exit(0)
|
376
389
|
end
|
377
390
|
|
378
|
-
# Undocumented feature
|
391
|
+
# Undocumented feature: open Github project with default web browser on a Mac
|
379
392
|
parser.on('', '--open-project') do
|
380
393
|
open_resource(PROJECT_URL)
|
381
394
|
exit(0)
|
382
395
|
end
|
383
396
|
|
397
|
+
parser.on('', '--project-url') do
|
398
|
+
puts PROJECT_URL
|
399
|
+
exit(0)
|
400
|
+
end
|
401
|
+
|
384
402
|
end.parse!
|
385
403
|
|
386
404
|
# We want to do this after all options have been processed because we don't want any clearing of the
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|