rexe 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/exe/rexe +15 -14
- 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: cfda8c2ee84b6747e85e1ba54954fefab0da7e246916808994c67976b291e714
|
4
|
+
data.tar.gz: c2221ed77248835efaf56f0f10ffe31803eca929760f67b0c274ac2ed4c1d423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b6809b8e4dc6b66cca019993eed4cfcddb65a80c75abcfccb9986206f8f59c1e2d3f4c128bff587899a24c32aeb13a082b5b597ada934b785390f9322ae46c7
|
7
|
+
data.tar.gz: 5127aa52ded297c3a53529b23174f6ec1fa397c59033fd4da5bca0adc700eccd12327c84abab9e644171384a1cabf653a523bbcee8dd96b8ea4abdf17a049243
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
## rexe -- Ruby Command Line Executor
|
2
2
|
|
3
3
|
|
4
|
+
### v0.3.1
|
5
|
+
|
6
|
+
* Help text fixes.
|
7
|
+
|
8
|
+
|
9
|
+
### v0.3.0
|
10
|
+
|
11
|
+
* For consistency with requires, specifying multiple load files on the command line can be done
|
12
|
+
with comma separated filespecs.
|
13
|
+
|
14
|
+
|
4
15
|
### v0.2.0
|
5
16
|
|
6
17
|
* Improve README and verbose logging.
|
data/exe/rexe
CHANGED
@@ -11,7 +11,7 @@ require 'shellwords'
|
|
11
11
|
# Rexe - Ruby Executor
|
12
12
|
class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
13
13
|
|
14
|
-
VERSION = '0.
|
14
|
+
VERSION = '0.3.1'
|
15
15
|
|
16
16
|
def initialize
|
17
17
|
self.input_mode = :string
|
@@ -31,14 +31,14 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
31
31
|
Options:
|
32
32
|
|
33
33
|
-h, --help Print help and exit
|
34
|
-
-l, --load
|
34
|
+
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated
|
35
35
|
-m, --mode MODE Mode with which to handle input (i.e. what `self` will be in the code):
|
36
36
|
-ms for each line to be handled separately as a string (default)
|
37
37
|
-me for an enumerator of lines (least memory consumption for big data)
|
38
38
|
-mb for 1 big string (all lines combined into single multiline string)
|
39
39
|
-mn to execute the specified Ruby code on no input at all
|
40
40
|
-r, --require REQUIRES Gems and built-in libraries (e.g. shellwords, yaml) to require, comma separated
|
41
|
-
-v, --[no-]verbose Verbose mode
|
41
|
+
-v, --[no-]verbose Verbose mode (logs to stderr)
|
42
42
|
|
43
43
|
If there is an .rexerc file in your home directory, it will be run as Ruby code
|
44
44
|
before processing the input.
|
@@ -62,6 +62,10 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
62
62
|
def parse_command_line
|
63
63
|
prepend_environment_options
|
64
64
|
|
65
|
+
add_comma_sep_tokens_to_array = ->(string, array) do
|
66
|
+
string.split(',').map(&:strip).each { |r| array << r }
|
67
|
+
end
|
68
|
+
|
65
69
|
OptionParser.new do |parser|
|
66
70
|
|
67
71
|
parser.on("-h", "--help", "Show help") do |_help_requested|
|
@@ -69,12 +73,12 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
69
73
|
exit
|
70
74
|
end
|
71
75
|
|
72
|
-
parser.on('-l', '--load RUBY_FILE', '
|
73
|
-
self.loads
|
76
|
+
parser.on('-l', '--load RUBY_FILE(S)', 'Ruby file(s) to load, comma separated') do |v|
|
77
|
+
add_comma_sep_tokens_to_array.(v, self.loads)
|
74
78
|
end
|
75
79
|
|
76
80
|
parser.on('-m', '--mode MODE',
|
77
|
-
'Mode with which to handle input (-ms
|
81
|
+
'Mode with which to handle input (-ms (default), -me, -mb, mn)') do |v|
|
78
82
|
|
79
83
|
modes = {
|
80
84
|
's' => :string,
|
@@ -90,11 +94,12 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
93
|
-
parser.on('-r', '--require
|
94
|
-
|
97
|
+
parser.on('-r', '--require REQUIRE(S)',
|
98
|
+
'Gems and built-in libraries (e.g. shellwords, yaml) to require, comma separated') do |v|
|
99
|
+
add_comma_sep_tokens_to_array.(v, self.requires)
|
95
100
|
end
|
96
101
|
|
97
|
-
parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|
|
102
|
+
parser.on('-v', '--[no-]verbose', 'Verbose mode (logs to stderr)') do |v|
|
98
103
|
self.verbose = v
|
99
104
|
end
|
100
105
|
end.parse!
|
@@ -135,23 +140,21 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
135
140
|
|
136
141
|
log_if_verbose("rexe version #{VERSION} -- #{Time.now}")
|
137
142
|
log_if_verbose('Source Code: ' + ARGV.join(' '))
|
143
|
+
log_if_verbose('Options: ' + self.to_h.to_s)
|
138
144
|
|
139
145
|
requires.each do |r|
|
140
|
-
log_if_verbose("Requiring #{r}")
|
141
146
|
require(r)
|
142
147
|
end
|
143
148
|
|
144
149
|
load_global_config_if_exists
|
145
150
|
|
146
151
|
loads.each do |file|
|
147
|
-
log_if_verbose("Loading #{file}")
|
148
152
|
load(file)
|
149
153
|
end
|
150
154
|
|
151
155
|
source_code = "Proc.new { #{ARGV.join(' ')} }"
|
152
156
|
code = eval(source_code)
|
153
157
|
|
154
|
-
|
155
158
|
actions = {
|
156
159
|
string: -> { STDIN.each { |l| execute(l.chomp, code) } },
|
157
160
|
enumerator: -> { execute(STDIN.each_line, code) },
|
@@ -170,5 +173,3 @@ end
|
|
170
173
|
# and must not have it run at that time:
|
171
174
|
called_as_script = (File.basename($0) == File.basename(__FILE__))
|
172
175
|
Rexe.new.call if called_as_script
|
173
|
-
|
174
|
-
|
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.3.1
|
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-02-
|
11
|
+
date: 2019-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|