rexe 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +4 -0
- data/README.md +7 -2
- data/exe/rexe +31 -5
- 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: f28a8f0593a9ba5033d80d5f6be579a3f6bea8b590769576830017c0e2c937e5
|
4
|
+
data.tar.gz: 564ed18f9d4b5976e5e34ed5cb6f14ffb249e2971fc2973b78ccd474b14fe3cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80288862464f30164044d0da18944bb5b28b6f8a3dc434a030b351b670be84f088be8d09e7e4f694c452fdf85e06469e4d9d96a5a629b30cd06694dfb6af9aa2
|
7
|
+
data.tar.gz: 353a94f6442280feb8e2a69123415651a9cfc21d9bf1e4fae3d50721f96abdf9b95863382b381bb906834132d4e641d4de7938ef3cc60c7fb88e75135cc1be96
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## rexe -- Ruby Command Line Executor
|
2
2
|
|
3
|
+
### v0.8.0
|
4
|
+
|
5
|
+
* Add no-op mode to suppress execution of code (useful with -v).
|
6
|
+
* Add clear mode to clear all options specified up to that point (useful to ignore REXE_OPTIONS environment variable settings).
|
3
7
|
|
4
8
|
### v0.7.0
|
5
9
|
|
data/README.md
CHANGED
@@ -27,19 +27,21 @@ but it is also a _filter_ in that it can implicitly consume standard input and e
|
|
27
27
|
As a summary, here is the help text printed out by the application:
|
28
28
|
|
29
29
|
```
|
30
|
-
rexe -- Ruby Command Line Filter/Executor -- v0.
|
30
|
+
rexe -- Ruby Command Line Filter/Executor -- v0.8.0 -- https://github.com/keithrbennett/rexe
|
31
31
|
|
32
32
|
Executes Ruby code on the command line, optionally taking standard input and writing to standard output.
|
33
33
|
|
34
34
|
Options:
|
35
35
|
|
36
|
+
-c --clear_options Clear all previous command line options specified up to now
|
36
37
|
-h, --help Print help and exit
|
37
38
|
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated, or ! to clear
|
38
39
|
-m, --mode MODE Mode with which to handle input (i.e. what `self` will be in the code):
|
39
40
|
-ms for each line to be handled separately as a string
|
40
41
|
-me for an enumerator of lines (least memory consumption for big data)
|
41
42
|
-mb for 1 big string (all lines combined into single multiline string)
|
42
|
-
-mn
|
43
|
+
-mn don't do special handling of input; self is not the input (default)
|
44
|
+
-n', --[no-]noop Do not execute the code (useful with -v)
|
43
45
|
-r, --require REQUIRES Gems and built-in libraries to require, comma separated, or ! to clear
|
44
46
|
-v, --[no-]verbose verbose mode (logs to stderr); to disable, short options: -v n, -v false
|
45
47
|
|
@@ -48,6 +50,9 @@ before processing the input.
|
|
48
50
|
|
49
51
|
If there is a REXE_OPTIONS environment variable, its content will be prepended to the command line
|
50
52
|
so that you can specify options implicitly (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
|
53
|
+
|
54
|
+
For boolean verbose and noop options, the following are valid:
|
55
|
+
-v no, -v yes, -v false, -v true, -v n, -v y, -v +, but not -v -
|
51
56
|
```
|
52
57
|
|
53
58
|
### Input Mode
|
data/exe/rexe
CHANGED
@@ -7,15 +7,22 @@
|
|
7
7
|
require 'optparse'
|
8
8
|
require 'shellwords'
|
9
9
|
|
10
|
-
class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
10
|
+
class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose, :noop)
|
11
11
|
|
12
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.8.0'
|
13
13
|
|
14
14
|
def initialize
|
15
|
+
clear_options
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# Used as an initializer and also when `-!` is specified on the command line.
|
20
|
+
def clear_options
|
15
21
|
self.input_mode = :no_input
|
16
22
|
self.loads = []
|
17
23
|
self.requires = []
|
18
24
|
self.verbose = false
|
25
|
+
self.noop = false
|
19
26
|
end
|
20
27
|
|
21
28
|
|
@@ -28,13 +35,15 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
28
35
|
|
29
36
|
Options:
|
30
37
|
|
38
|
+
-c --clear_options Clear all previous command line options specified up to now
|
31
39
|
-h, --help Print help and exit
|
32
40
|
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated, or ! to clear
|
33
41
|
-m, --mode MODE Mode with which to handle input (i.e. what `self` will be in the code):
|
34
42
|
-ms for each line to be handled separately as a string
|
35
43
|
-me for an enumerator of lines (least memory consumption for big data)
|
36
44
|
-mb for 1 big string (all lines combined into single multiline string)
|
37
|
-
-mn
|
45
|
+
-mn don't do special handling of input; self is not the input (default)
|
46
|
+
-n', --[no-]noop Do not execute the code (useful with -v)
|
38
47
|
-r, --require REQUIRES Gems and built-in libraries to require, comma separated, or ! to clear
|
39
48
|
-v, --[no-]verbose verbose mode (logs to stderr); to disable, short options: -v n, -v false
|
40
49
|
|
@@ -44,6 +53,9 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
44
53
|
If there is a REXE_OPTIONS environment variable, its content will be prepended to the command line
|
45
54
|
so that you can specify options implicitly (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
|
46
55
|
|
56
|
+
For boolean verbose and noop options, the following are valid:
|
57
|
+
-v no, -v yes, -v false, -v true, -v n, -v y, -v +, but not -v -
|
58
|
+
|
47
59
|
HEREDOC
|
48
60
|
end
|
49
61
|
|
@@ -115,12 +127,22 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
115
127
|
self.verbose = (v.nil? ? true : v)
|
116
128
|
end
|
117
129
|
|
130
|
+
parser.on('-c', '--clear_options', "Clear all previous command line options") do |v|
|
131
|
+
clear_options
|
132
|
+
end
|
133
|
+
|
134
|
+
parser.on('-n', '--[no-]noop [FLAG]', TrueClass, "Do not execute the code (useful with -v)") do |v|
|
135
|
+
self.noop = (v.nil? ? true : v)
|
136
|
+
end
|
118
137
|
|
119
138
|
parser.on('', '--version', 'Print version') do
|
120
139
|
puts VERSION
|
121
140
|
exit
|
122
141
|
end
|
123
142
|
end.parse!
|
143
|
+
|
144
|
+
requires.uniq!
|
145
|
+
loads.uniq!
|
124
146
|
end
|
125
147
|
|
126
148
|
|
@@ -172,11 +194,15 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
172
194
|
actions = {
|
173
195
|
string: -> { STDIN.each { |l| execute(l.chomp, code) } },
|
174
196
|
enumerator: -> { execute(STDIN.each_line, code) },
|
175
|
-
one_big_string: -> { big_string = STDIN.
|
197
|
+
one_big_string: -> { big_string = STDIN.read; execute(big_string, code) },
|
176
198
|
no_input: -> { execute(nil, code) }
|
177
199
|
}
|
178
200
|
|
179
|
-
|
201
|
+
if self.noop
|
202
|
+
log_if_verbose("No-op mode requested; not executing code.")
|
203
|
+
else
|
204
|
+
actions[input_mode].()
|
205
|
+
end
|
180
206
|
|
181
207
|
duration = Time.now - start_time
|
182
208
|
log_if_verbose("rexe time elapsed: #{duration} seconds.")
|
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: 0.
|
4
|
+
version: 0.8.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-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|