rexe 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +36 -22
- data/exe/rexe +2 -2
- 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: 606431741970f4fde8a4d54e93c788af091f7422868b2f5975477a217767497c
|
4
|
+
data.tar.gz: 326d91170d3759fdb35f74eceb4bf308ff545ee8cebff1a8e22699de6e9f7a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722be782787590850d8651fc2afb9040f617c26b376713e0aee52d73ddc5765c9d412cdb852542d5ef5705a8a0136738125a0d5ed4af2d3c080093345d82684f
|
7
|
+
data.tar.gz: e1a97fae20c9bdeb2db1db74e76c41342461689222225ee875fa02d6a4e2af0b78ab8208b3db4110f6ba68fc39e1e3b917fc62c9e41b46cc5ff24eee11792bae
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,8 +3,10 @@ title: The `rexe` Command Line Executor and Filter
|
|
3
3
|
date: 2019-02-15
|
4
4
|
---
|
5
5
|
|
6
|
-
[Caution: This is a long article! If you lose patience reading it, I suggest skimming the headings
|
7
|
-
and the source code, and at minimum, reading the Conclusion.]
|
6
|
+
_[Caution: This is a long article! If you lose patience reading it, I suggest skimming the headings
|
7
|
+
and the source code, and at minimum, reading the Conclusion.]_
|
8
|
+
|
9
|
+
----
|
8
10
|
|
9
11
|
I love the power of the command line, but not the awkwardness of shell scripting
|
10
12
|
languages. Sure, there's a lot that can be done with them, but it doesn't take
|
@@ -57,7 +59,7 @@ line, tipping the scale so that it is practical to do it more often.
|
|
57
59
|
Here is `rexe`'s help text as of the time of this writing:
|
58
60
|
|
59
61
|
```
|
60
|
-
rexe -- Ruby Command Line Executor/Filter -- v0.10.
|
62
|
+
rexe -- Ruby Command Line Executor/Filter -- v0.10.3 -- https://github.com/keithrbennett/rexe
|
61
63
|
|
62
64
|
Executes Ruby code on the command line, optionally taking standard input and writing to standard output.
|
63
65
|
|
@@ -101,15 +103,13 @@ so that you can specify options implicitly (e.g. `export REXE_OPTIONS="-r awesom
|
|
101
103
|
-v no, -v yes, -v false, -v true, -v n, -v y, -v +, but not -v -
|
102
104
|
```
|
103
105
|
|
104
|
-
### Simplifying the Rexe Invocation
|
106
|
+
### Simplifying the Rexe Invocation
|
105
107
|
|
106
|
-
|
108
|
+
There are two main ways we can simplify the `rexe` command line:
|
107
109
|
|
108
|
-
* the `REXE_OPTIONS` environment variable
|
109
|
-
*
|
110
|
-
|
111
|
-
These approaches enable removing configuration information from your `rexe` command,
|
112
|
-
making it shorter and simpler to read.
|
110
|
+
* by extracting configuration into the `REXE_OPTIONS` environment variable
|
111
|
+
* by extracting low level and/or shared code into files that are loaded using `-l`,
|
112
|
+
or implicitly with `~/.rexerc`
|
113
113
|
|
114
114
|
|
115
115
|
### The REXE_OPTIONS Environment Variable
|
@@ -333,19 +333,35 @@ If you may have more input than would fit in memory, you can do the following:
|
|
333
333
|
* use [lazy enumerators](https://www.honeybadger.io/blog/using-lazy-enumerators-to-work-with-large-files-in-ruby/)
|
334
334
|
|
335
335
|
|
336
|
+
### Input Formats
|
337
|
+
|
338
|
+
`rexe` can parse your input in any of several formats if you like.
|
339
|
+
You would request this in the _input format_ (`-i`) option.
|
340
|
+
Legal values are:
|
341
|
+
|
342
|
+
* `-ij` - JSON
|
343
|
+
* `-im` - Marshal
|
344
|
+
* `-in` - [None] (default)
|
345
|
+
* `-iy` - YAML
|
346
|
+
|
347
|
+
Except for `-in`, which passes the text to your code untouched, your input will be parsed
|
348
|
+
in the specified format, and the resulting object passed into your code as `self`.
|
349
|
+
|
350
|
+
The input format option is ignored if the input _mode_ is `-mn` ("no input" executor mode, the default),
|
351
|
+
since there is no preprocessing of standard input in that mode.
|
336
352
|
|
337
353
|
### Output Formats
|
338
354
|
|
339
|
-
Several output formats are provided for your convenience. Here they are
|
355
|
+
Several output formats are provided for your convenience. Here they are:
|
340
356
|
|
341
|
-
* `-oa`
|
342
|
-
* `-oi`
|
343
|
-
* `-oj`
|
344
|
-
* `-oJ`
|
345
|
-
* `-on`
|
346
|
-
* `-op`
|
347
|
-
* `-os`
|
348
|
-
* `-oy`
|
357
|
+
* `-oa` - Awesome Print - calls `.ai` on the object to get the string that `ap` would print
|
358
|
+
* `-oi` - Inspect - calls `inspect` on the object
|
359
|
+
* `-oj` - JSON - calls `to_json` on the object
|
360
|
+
* `-oJ` - Pretty JSON calls `JSON.pretty_generate` with the object
|
361
|
+
* `-on` - No Output - output is suppressed
|
362
|
+
* `-op` - Puts - produces what `puts` would output
|
363
|
+
* `-os` - To String - calls `to_s` on the object
|
364
|
+
* `-oy` - YAML - calls `to_yaml` on the object
|
349
365
|
|
350
366
|
All formats will implicitly `require` anything needed to accomplish their task (e.g. `require 'yaml'`).
|
351
367
|
|
@@ -496,8 +512,6 @@ interpreter sees your code, it's all in a single line. Adding the semicolon fixe
|
|
496
512
|
```
|
497
513
|
➜ ~ cowsay hello | rexe -me "print %Q{\u001b[33m}; \
|
498
514
|
puts to_a"
|
499
|
-
|
500
|
-
eval_context_object: #<Enumerator:0x00007f92b1972840>
|
501
515
|
_______
|
502
516
|
< hello >
|
503
517
|
-------
|
@@ -723,7 +737,7 @@ A word of caution though --
|
|
723
737
|
the complexity and difficulty of sharing your `rexe` scripts across systems
|
724
738
|
will be proportional to the extent to which you use environment variables
|
725
739
|
and loaded files for configuration and shared code.
|
726
|
-
Be responsible and disciplined in making this configuration as organized as possible.
|
740
|
+
Be responsible and disciplined in making this configuration and code as organized as possible.
|
727
741
|
|
728
742
|
#### Footnotes
|
729
743
|
|
data/exe/rexe
CHANGED
@@ -10,7 +10,7 @@ require 'shellwords'
|
|
10
10
|
|
11
11
|
class Rexe < Struct.new(:input_format, :input_mode, :loads, :output_format, :requires, :verbose, :noop)
|
12
12
|
|
13
|
-
VERSION = '0.10.
|
13
|
+
VERSION = '0.10.3'
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
clear_options
|
@@ -218,7 +218,7 @@ class Rexe < Struct.new(:input_format, :input_mode, :loads, :output_format, :req
|
|
218
218
|
|
219
219
|
|
220
220
|
def execute(eval_context_object, code)
|
221
|
-
|
221
|
+
if input_format != :none && input_mode != :no_input
|
222
222
|
eval_context_object = input_parser.(eval_context_object)
|
223
223
|
end
|
224
224
|
|
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.10.
|
4
|
+
version: 0.10.3
|
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-03-
|
11
|
+
date: 2019-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|