rexe 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +76 -76
  4. data/exe/rexe +6 -6
  5. data/rexe.gemspec +1 -1
  6. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98d61cacefb21278637d8a35075b6e2014fcae19a52e54007384a714969d321c
4
- data.tar.gz: 25fcf9606fe2240d738d5e5f13fd4633f4140a303a9f795d43412abd2ddb1a35
3
+ metadata.gz: b7477c149efa64d0b00e4127d5219546c7ef1559fb7708ca8b389a9ef48c7348
4
+ data.tar.gz: 76114118d28be5a81561f8c67af9727fca5201a5ca443d0cdc6d60f5431451a1
5
5
  SHA512:
6
- metadata.gz: 329c13abe06449ca89b6be6bf860dcb0984f43a7239c9656df1e9d1c0346f80b4ba6b619afb3dbc3403649929718020cb597b54bca8a6b78bb73f468625eabd5
7
- data.tar.gz: d265562124a741dea95fb3262f899405f13f05281f07e68f5b43ca1caaf2366d14d7ca1aa1c909386e852b94ec06b4598423a0178bf1b8188d0d0c7cbc0d252b
6
+ metadata.gz: 615ff910e6a79cdc38b574503253871e5141bf027f6753aaa2375a4b8e2a4108f2ebdd6eb4532dbd46daf655212ac8f6583b538f103164abcc1264e84ae71450
7
+ data.tar.gz: 6cd017a263416d521de4c1a8b55cdba5fb55605a053d3bb39e019c1521f19c1549eeed715cc9c8c37e90dbe7109681a27de56ee8ef6e53ffa41c337ebd2fb29a
@@ -1,10 +1,15 @@
1
1
  ## rexe -- Ruby Command Line Executor/Filter
2
2
 
3
+ ### 1.5.0
4
+
5
+ * Switch from AwesomePrint to AmazingPrint, and change all references in text, help, etc.
6
+
3
7
 
4
8
  ### 1.4.1
5
9
 
6
10
  * As of later versions of Ruby, `stringio` is a gem and must be required. Fixed.
7
11
 
12
+
8
13
  ### 1.4.0
9
14
 
10
15
  * Handle Bundler deprecation of `with_clean_env` method.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  __Rexe__ is a Ruby script and gem that multiplies Ruby's usefulness and conciseness on the command line by:
4
4
 
5
- * automating parsing and formatting using JSON, YAML, Ruby marshalling, Awesome Print, and others
5
+ * automating parsing and formatting using JSON, YAML, Ruby marshalling, Amazing Print, and others
6
6
  * simplifying the use of Ruby as a shell filter, optionally predigesting input as lines, an enumerator, or one big string
7
7
  * extracting the plumbing from the command line; requires and other options can be set in an environment variable
8
8
  * enabling the loading of Ruby helper files to keep your code DRY and your command line code high level
@@ -24,8 +24,8 @@ Sometimes a good solution is to combine Ruby and shell scripting on the same com
24
24
  Let's start by seeing what the Ruby interpreter already provides. Here we use `ruby` on the command line, using an intermediate environment variable to simplify the logic and save the data for use by future commands. An excerpt of the output follows the code:
25
25
 
26
26
  ```bash
27
- ➜ ~  export EUR_RATES_JSON=`curl https://api.exchangeratesapi.io/latest`
28
- ➜ ~  echo $EUR_RATES_JSON | ruby -r json -r yaml -e 'puts JSON.parse(STDIN.read).to_yaml'
27
+ $ export EUR_RATES_JSON=`curl https://api.exchangeratesapi.io/latest`
28
+ $ echo $EUR_RATES_JSON | ruby -r json -r yaml -e 'puts JSON.parse(STDIN.read).to_yaml'
29
29
  ```
30
30
  ```yaml
31
31
  ---
@@ -45,13 +45,13 @@ Unfortunately, the configuration setup (the `require`s) along with the reading,
45
45
  Rexe [see footnote ^1 regarding its origin] can simplify such commands. Among other things, rexe provides switch-activated input parsing and output formatting so that converting from one format to another is trivial. The previous `ruby` command can be expressed in `rexe` as:
46
46
 
47
47
  ```bash
48
- ➜ ~  echo $EUR_RATES_JSON | rexe -mb -ij -oy self
48
+ $ echo $EUR_RATES_JSON | rexe -mb -ij -oy self
49
49
  ```
50
50
 
51
51
  Or, even more concisely (`self` is the default Ruby source code for rexe commands):
52
52
 
53
53
  ```bash
54
- ➜ ~  echo $EUR_RATES_JSON | rexe -mb -ij -oy
54
+ $ echo $EUR_RATES_JSON | rexe -mb -ij -oy
55
55
  ```
56
56
 
57
57
  The command options may seem cryptic, but they're logical so it shouldn't take long to learn them:
@@ -63,7 +63,7 @@ The command options may seem cryptic, but they're logical so it shouldn't take l
63
63
  If input comes from a JSON or YAML file, rexe determines the input format from the file's extension, and it's even simpler:
64
64
 
65
65
  ```bash
66
- ➜ ~  rexe -f eur_rates.json -oy
66
+ $ rexe -f eur_rates.json -oy
67
67
  ```
68
68
 
69
69
  Rexe is at https://github.com/keithrbennett/rexe and can be installed with `gem install rexe`. Rexe provides several ways to simplify Ruby on the command line, tipping the scale so that it is practical to do it more often.
@@ -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.3.1 -- https://github.com/keithrbennett/rexe
76
+ rexe -- Ruby Command Line Executor/Filter -- v1.5.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,
@@ -107,7 +107,7 @@ Options:
107
107
  -n, --[no-]noop Do not execute the code (useful with -g);
108
108
  For true: yes, true, y, +; for false: no, false, n
109
109
  -o, --output_format FORMAT Output format, defaults to -on (no output):
110
- -oa Awesome Print
110
+ -oa Amazing Print
111
111
  -oi Inspect
112
112
  -oj JSON
113
113
  -oJ Pretty JSON
@@ -135,7 +135,7 @@ before processing the input.
135
135
 
136
136
  If there is a REXE_OPTIONS environment variable, its content will be prepended
137
137
  to the command line so that you can specify options implicitly
138
- (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
138
+ (e.g. `export REXE_OPTIONS="-r amazing_print,yaml"`)
139
139
  ```
140
140
 
141
141
  ### Simplifying the Rexe Invocation
@@ -154,15 +154,15 @@ The `REXE_OPTIONS` environment variable can contain command line options that wo
154
154
  Instead of this:
155
155
 
156
156
  ```bash
157
- ➜ ~  rexe -r wifi-wand -oa WifiWand::MacOsModel.new.wifi_info
157
+ $ rexe -r wifi-wand -oa WifiWand::MacOsModel.new.wifi_info
158
158
  ```
159
159
 
160
160
  you can do this:
161
161
 
162
162
  ```bash
163
- ➜ ~  export REXE_OPTIONS="-r wifi-wand -oa"
164
- ➜ ~  rexe WifiWand::MacOsModel.new.wifi_info
165
- ➜ ~  # [more rexe commands with the same options]
163
+ $ export REXE_OPTIONS="-r wifi-wand -oa"
164
+ $ rexe WifiWand::MacOsModel.new.wifi_info
165
+ $ # [more rexe commands with the same options]
166
166
  ```
167
167
 
168
168
  Putting configuration options in `REXE_OPTIONS` effectively creates custom defaults, and is useful when you use the same options in most or all of your commands. Any options specified on the rexe command line will override the environment variable options.
@@ -189,7 +189,7 @@ To digress a bit, why would you want this? You might want to be able to go to an
189
189
  Here is an example of how you might use the `valkyries` method, assuming the above configuration is loaded from your `~/.rexerc` file or an explicitly loaded file:
190
190
 
191
191
  ```bash
192
- ➜ ~  tar czf /tmp/my-whole-user-space.tar.gz ~ ; rexe valkyries
192
+ $ tar czf /tmp/my-whole-user-space.tar.gz ~ ; rexe valkyries
193
193
  ```
194
194
 
195
195
  (Note that `;` is used rather than `&&` because we want to hear the music whether or not the command succeeds.)
@@ -213,7 +213,7 @@ end
213
213
  ...which you could then call like this:
214
214
 
215
215
  ```bash
216
- ➜ ~  tar czf /tmp/my-whole-user-space.tar.gz ~ ; rexe 'play(:hallelujah)'
216
+ $ tar czf /tmp/my-whole-user-space.tar.gz ~ ; rexe 'play(:hallelujah)'
217
217
  ```
218
218
 
219
219
  (You need to quote the `play` call because otherwise the shell will process and remove the parentheses. Alternatively you could escape the parentheses with backslashes.)
@@ -226,7 +226,7 @@ One of the examples at the end of this articles shows how you could have differe
226
226
  A log entry is optionally output to standard error after completion of the code. This entry is a hash representation (to be precise, `to_h`) of the `$RC` OpenStruct described in the $RC section below. It contains the version, date/time of execution, source code to be evaluated, options (after parsing both the `REXE_OPTIONS` environment variable and the command line), and the execution time of your Ruby code:
227
227
 
228
228
  ```bash
229
- ➜ ~  echo $EUR_RATES_JSON | rexe -gy -ij -mb -oa -n self
229
+ $ echo $EUR_RATES_JSON | rexe -gy -ij -mb -oa -n self
230
230
  ```
231
231
  ```yaml
232
232
  ---
@@ -239,11 +239,11 @@ A log entry is optionally output to standard error after completion of the code.
239
239
  :input_format: :json
240
240
  :input_mode: :one_big_string
241
241
  :loads: []
242
- :output_format: :awesome_print
243
- :output_format_tty: :awesome_print
244
- :output_format_block: :awesome_print
242
+ :output_format: :amazing_print
243
+ :output_format_tty: :amazing_print
244
+ :output_format_block: :amazing_print
245
245
  :requires:
246
- - awesome_print
246
+ - amazing_print
247
247
  - json
248
248
  - yaml
249
249
  :log_format: :yaml
@@ -260,7 +260,7 @@ This extra output is sent to standard error (_stderr_) instead of standard outpu
260
260
  If you would like to append this informational output to a file(e.g. `rexe.log`), you could do something like this:
261
261
 
262
262
  ```bash
263
- ➜ ~  rexe ... -gy 2>>rexe.log
263
+ $ rexe ... -gy 2>>rexe.log
264
264
  ```
265
265
 
266
266
 
@@ -288,7 +288,7 @@ The last (and default) is the _executor_ mode. It merely assists you in executin
288
288
  In this mode, your code would be called once per line of input, and in each call, `self` would evaluate to each line of text:
289
289
 
290
290
  ```bash
291
- ➜ ~  echo "hello\ngoodbye" | rexe -ml puts reverse
291
+ $ echo "hello\ngoodbye" | rexe -ml puts reverse
292
292
  olleh
293
293
  eybdoog
294
294
  ```
@@ -310,7 +310,7 @@ Dealing with input as an enumerator enables you to use the wealth of `Enumerable
310
310
  Here is an example of using `-me` to add line numbers to the first 3 files in the directory listing:
311
311
 
312
312
  ```bash
313
- ➜ ~  ls / | rexe -me "first(3).each_with_index { |ln,i| puts '%5d %s' % [i, ln] }"
313
+ $ ls / | rexe -me "first(3).each_with_index { |ln,i| puts '%5d %s' % [i, ln] }"
314
314
 
315
315
  0 AndroidStudioProjects
316
316
  1 Applications
@@ -363,7 +363,7 @@ The input format option is ignored if the input _mode_ is `-mn` ("no input" exec
363
363
 
364
364
  Several output formats are provided for your convenience:
365
365
 
366
- * `-oa` - Awesome Print - calls `.ai` on the object to get the string that `ap` would print
366
+ * `-oa` - Amazing Print - calls `.ai` on the object to get the string that `ap` would print
367
367
  * `-oi` - Inspect - calls `inspect` on the object
368
368
  * `-oj` - JSON - calls `to_json` on the object
369
369
  * `-oJ` - Pretty JSON calls `JSON.pretty_generate` with the object
@@ -390,12 +390,12 @@ You may wonder why these formats are provided, given that their functionality co
390
390
  Rexe also simplifies getting input from a file rather than standard input. The `-f` option takes a filespec and does with its content exactly what it would have done with standard input. This shortens:
391
391
 
392
392
  ```bash
393
- ➜ ~  cat filename.ext | rexe ...
393
+ $ cat filename.ext | rexe ...
394
394
  ```
395
395
  ...to...
396
396
 
397
397
  ```bash
398
- ➜ ~  rexe -f filename.ext ...
398
+ $ rexe -f filename.ext ...
399
399
  ```
400
400
 
401
401
  This becomes even more useful if you are using files whose extensions are `.yml`, `.yaml`, or `.json` (case insensitively). In this case the input format and mode will be set automatically for you to:
@@ -406,14 +406,14 @@ This becomes even more useful if you are using files whose extensions are `.yml`
406
406
  So the example we gave above:
407
407
 
408
408
  ```bash
409
- ➜ ~  export EUR_RATES_JSON=`curl https://api.exchangeratesapi.io/latest`
410
- ➜ ~  echo $EUR_RATES_JSON | rexe -mb -ij -oy self
409
+ $ export EUR_RATES_JSON=`curl https://api.exchangeratesapi.io/latest`
410
+ $ echo $EUR_RATES_JSON | rexe -mb -ij -oy self
411
411
  ```
412
412
  ...could be changed to:
413
413
 
414
414
  ```bash
415
- ➜ ~  curl https://api.exchangeratesapi.io/latest > eur_rates.json
416
- ➜ ~  rexe -f eur_rates.json -oy self
415
+ $ curl https://api.exchangeratesapi.io/latest > eur_rates.json
416
+ $ rexe -f eur_rates.json -oy self
417
417
  ```
418
418
 
419
419
  Another possible win for using `-f` is that since it is a command line option, it could be specified in `REXE_OPTIONS`. This could be useful if you are doing many operations on the same file.
@@ -421,7 +421,7 @@ Another possible win for using `-f` is that since it is a command line option, i
421
421
  If you need to override the input mode and format automatically configured for file input, you can simply specify the desired options on the command line _after_ the `-f`:
422
422
 
423
423
  ```bash
424
- ➜ ~  rexe -f eur_rates.json -mb -in 'puts self.class, self[0..20]'
424
+ $ rexe -f eur_rates.json -mb -in 'puts self.class, self[0..20]'
425
425
  String
426
426
  {"base":"EUR","rates"
427
427
  ```
@@ -452,7 +452,7 @@ This feature is probably only useful in the filter modes, since in the executor
452
452
  For your convenience, the information displayed in verbose mode is available to your code at runtime by accessing the `$RC` global variable, which contains an OpenStruct. Let's print out its contents using YAML:
453
453
 
454
454
  ```bash
455
- ➜ ~  rexe -oy '$RC'
455
+ $ rexe -oy '$RC'
456
456
  ```
457
457
  ```yaml
458
458
  --- !ruby/object:OpenStruct
@@ -479,7 +479,7 @@ modifiable: true
479
479
  Probably most useful in that object at runtime is the record count, accessible with both `$RC.count` and `$RC.i`. This is only really useful in line mode, because in the others it will always be 0 or 1. Here is an example of how you might use it as a kind of progress indicator:
480
480
 
481
481
  ```bash
482
- ➜ ~  find / | rexe -ml -on \
482
+ $ find / | rexe -ml -on \
483
483
  'if $RC.i % 1000 == 0; puts %Q{File entry ##{$RC.i} is #{self}}; end'
484
484
  ```
485
485
  ```
@@ -498,22 +498,22 @@ Note that a single quote was used for the Ruby code here; if a double quote were
498
498
  Defining methods in your loaded files enables you to effectively define a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) for your command line use. You could use different load files for different projects, domains, or contexts, and define aliases or one line scripts to give them meaningful names. For example, if you had Ansible helper code in `~/projects/ansible-tools/rexe-ansible.rb`, you could define an alias in your startup script:
499
499
 
500
500
  ```bash
501
- ➜ ~  alias rxans="rexe -l ~/projects/ansible-tools/rexe-ansible.rb $*"
501
+ $ alias rxans="rexe -l ~/projects/ansible-tools/rexe-ansible.rb $*"
502
502
  ```
503
503
  ...and then you would have an Ansible DSL available for me to use by calling `rxans`.
504
504
 
505
505
  In addition, since you can also call `pry` on the context of any object, you can provide a DSL in a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) (shell) trivially easily. Just to illustrate, here's how you would open a REPL on the File class:
506
506
 
507
507
  ```bash
508
- ➜ ~  ruby -r pry -e File.pry
508
+ $ ruby -r pry -e File.pry
509
509
  # or
510
- ➜ ~  rexe -r pry File.pry
510
+ $ rexe -r pry File.pry
511
511
  ```
512
512
 
513
513
  `self` would evaluate to the `File` class, so you could call class methods using only their names:
514
514
 
515
515
  ```bash
516
- ➜ ~  rexe -r pry File.pry
516
+ $ rexe -r pry File.pry
517
517
  ```
518
518
  ```
519
519
  [6] pry(File)> size '/etc/passwd'
@@ -527,7 +527,7 @@ true
527
527
  This could be really handy if you call `pry` on a custom object that has methods especially suited to your task:
528
528
 
529
529
  ```bash
530
- ➜ ~  rexe -r wifi-wand,pry WifiWand::MacOsModel.new.pry
530
+ $ rexe -r wifi-wand,pry WifiWand::MacOsModel.new.pry
531
531
  ```
532
532
  ```
533
533
  [1] pry(#<WifiWand::MacOsModel>)> random_mac_address
@@ -548,25 +548,25 @@ Personally, I find single quotes more useful since I usually don't want special
548
548
  Sometimes it doesn't matter:
549
549
 
550
550
  ```bash
551
- ➜ ~  rexe 'puts "hello"'
551
+ $ rexe 'puts "hello"'
552
552
  hello
553
- ➜ ~  rexe "puts 'hello'"
553
+ $ rexe "puts 'hello'"
554
554
  hello
555
555
  ```
556
556
 
557
557
  We can also use `%q` or `%Q`, and sometimes this eliminates the needs for the outer quotes altogether:
558
558
 
559
559
  ```bash
560
- ➜ ~  rexe puts %q{hello}
560
+ $ rexe puts %q{hello}
561
561
  hello
562
- ➜ ~  rexe puts %Q{hello}
562
+ $ rexe puts %Q{hello}
563
563
  hello
564
564
  ```
565
565
 
566
566
  Sometimes the quotes to use on the outside (quoting your command in the shell) need to be chosen based on which quotes are needed on the inside. For example, in the following command, we need double quotes in Ruby in order for interpolation to work, so we use single quotes on the outside:
567
567
 
568
568
  ```bash
569
- ➜ ~  rexe puts '"The time is now #{Time.now}"'
569
+ $ rexe puts '"The time is now #{Time.now}"'
570
570
  ```
571
571
  ```
572
572
  The time is now 2019-03-29 16:41:26 +0800
@@ -575,7 +575,7 @@ The time is now 2019-03-29 16:41:26 +0800
575
575
  In this case we also need to use single quotes on the outside, because we need literal double quotes in a `%Q{}` expression:
576
576
 
577
577
  ```bash
578
- ➜ ~  rexe 'puts %Q{The operating system name is "#{`uname`.chomp}".}'
578
+ $ rexe 'puts %Q{The operating system name is "#{`uname`.chomp}".}'
579
579
  ```
580
580
  ```
581
581
  The operating system name is "Darwin".
@@ -584,7 +584,7 @@ The operating system name is "Darwin".
584
584
  We can eliminate the need for any quotes in the Ruby code using `%Q{}`:
585
585
 
586
586
  ```bash
587
- ➜ ~  rexe puts '%Q{The time is now #{Time.now}}'
587
+ $ rexe puts '%Q{The time is now #{Time.now}}'
588
588
  ```
589
589
  ```
590
590
  The time is now 2019-03-29 17:06:13 +0800
@@ -615,7 +615,7 @@ AUD BGN BRL CAD CHF CNY CZK DKK GBP HKD HRK HUF IDR ILS INR ISK JPY KRW MXN MYR
615
615
  The codes output are the legal arguments that could be sent to rexe's stdin as an argument in the command below. Let's find out the Euro exchange rate for _PHP_, Philippine Pesos:
616
616
 
617
617
  ```bash
618
- ➜ ~  echo PHP | rexe -ml -op -rjson \
618
+ $ echo PHP | rexe -ml -op -rjson \
619
619
  "rate = JSON.parse(ENV['EUR_RATES_JSON'])['rates'][self];\
620
620
  %Q{1 EUR = #{rate} #{self}}"
621
621
 
@@ -647,13 +647,13 @@ AUD BGN BRL PHP TRY USD ZAR
647
647
  We could manually select that text and use system menu commands or keys to copy it to the clipboard, or we could do this:
648
648
 
649
649
  ```bash
650
- ➜ ~  echo AUD BGN BRL PHP TRY USD ZAR | pbcopy
650
+ $ echo AUD BGN BRL PHP TRY USD ZAR | pbcopy
651
651
  ```
652
652
 
653
653
  After copying this line to the clipboard, we could run this:
654
654
 
655
655
  ```bash
656
- ➜ ~  pbpaste | rexe -ml -op \
656
+ $ pbpaste | rexe -ml -op \
657
657
  "split.map(&:downcase).map { |s| %Q{ #{s}: '',} }.join(%Q{\n})"
658
658
  aud: '',
659
659
  bgn: '',
@@ -672,7 +672,7 @@ Although rexe is cleanest with short one liners, you may want to use it to inclu
672
672
  What might not be so obvious is that you will often need to use semicolons as statement separators. For example, here is an example without a semicolon:
673
673
 
674
674
  ```bash
675
- ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m} \
675
+ $ cowsay hello | rexe -me "print %Q{\u001b[33m} \
676
676
  puts to_a"
677
677
  ```
678
678
  ```
@@ -684,13 +684,13 @@ rexe: (eval):1: syntax error, unexpected tIDENTIFIER, expecting '}'
684
684
  The shell combines all backslash terminated lines into a single line of text, so when the Ruby interpreter sees your code, it's all in a single line:
685
685
 
686
686
  ```bash
687
- ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m} puts to_a"
687
+ $ cowsay hello | rexe -me "print %Q{\u001b[33m} puts to_a"
688
688
  ```
689
689
 
690
690
  Adding the semicolon fixes the problem:
691
691
 
692
692
  ```bash
693
- ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m}; \
693
+ $ cowsay hello | rexe -me "print %Q{\u001b[33m}; \
694
694
  puts to_a"
695
695
  ```
696
696
  ```
@@ -714,7 +714,7 @@ There may be times when you have specified a load or require on the command line
714
714
  2) Unspecify individual requires or loads by preceding the name with `-`, e.g. `-r -rails`. Array subtraction is used, and array subtraction removes _all_ occurrences of each element of the subtracted (subtrahend) array, so:
715
715
 
716
716
  ```bash
717
- ➜ ~  rexe -n -r rails,rails,rails,-rails -gP
717
+ $ rexe -n -r rails,rails,rails,-rails -gP
718
718
  ...
719
719
  :requires=>["pp"],
720
720
  ...
@@ -725,7 +725,7 @@ There may be times when you have specified a load or require on the command line
725
725
  We could have also extracted the requires list programmatically using `$RC` (described above) by doing this:
726
726
 
727
727
  ```bash
728
- ➜ ~  rexe -oP -r rails,rails,rails,-rails '$RC[:options][:requires]'
728
+ $ rexe -oP -r rails,rails,rails,-rails '$RC[:options][:requires]'
729
729
  ["pp"]
730
730
  ```
731
731
 
@@ -740,9 +740,9 @@ You can also clear _all_ options specified up to a certain point in time with th
740
740
  For consistency with the `ruby` interpreter, rexe supports requires with the `-r` option, but also allows grouping them together using commas:
741
741
 
742
742
  ```bash
743
- vvvvvvvvvvvvvvvvvvvvv
744
- ➜ ~  echo $EUR_RATES_JSON | rexe -r json,awesome_print 'ap JSON.parse(STDIN.read)'
745
- ^^^^^^^^^^^^^^^^^^^^^
743
+ vvvvvvvvvvvvvvvvvv
744
+ $ echo $EUR_RATES_JSON | rexe -r json,amazing_print 'ap JSON.parse(STDIN.read)'
745
+ ^^^^^^^^^^^^^^^^^^
746
746
  ```
747
747
 
748
748
  Files loaded with the `-l` option are treated the same way.
@@ -753,9 +753,9 @@ Files loaded with the `-l` option are treated the same way.
753
753
  Requiring gems and modules for _all_ invocations of rexe will make your commands simpler and more concise, but will be a waste of execution time if they are not needed. You can inspect the execution times to see just how much time is being consumed. For example, we can find out that rails takes about 0.63 seconds to load on one system by observing and comparing the execution times with and without the require (output has been abbreviated using `grep`):
754
754
 
755
755
  ```bash
756
- ➜ ~  rexe -gy -r rails 2>&1 | grep duration
756
+ $ rexe -gy -r rails 2>&1 | grep duration
757
757
  :duration_secs: 0.660138
758
- ➜ ~  rexe -gy 2>&1 | grep duration
758
+ $ rexe -gy 2>&1 | grep duration
759
759
  :duration_secs: 0.027781
760
760
  ```
761
761
  (For the above to work, the `rails` gem and its dependencies need to be installed.)
@@ -777,29 +777,29 @@ Here are some more examples to illustrate the use of rexe.
777
777
  To output the result to stdout, you can either call `puts` or specify the `-op` option:
778
778
 
779
779
  ```bash
780
- ➜ ~  rexe puts 1 / 3.0
780
+ $ rexe puts 1 / 3.0
781
781
  0.3333333333333333
782
782
  ```
783
783
 
784
784
  or:
785
785
 
786
786
  ```bash
787
- ➜ ~  rexe -op 1 / 3.0
787
+ $ rexe -op 1 / 3.0
788
788
  0.3333333333333333
789
789
  ```
790
790
 
791
791
  Since `*` is interpreted by the shell, if we do multiplication, we need to quote the expression:
792
792
 
793
793
  ```bash
794
- ➜ ~  rexe -op '2 * 7'
794
+ $ rexe -op '2 * 7'
795
795
  14
796
796
  ```
797
797
 
798
798
  Of course, if you put the `-op` in the `REXE_OPTIONS` environment variable, you don't need to be explicit about the output:
799
799
 
800
800
  ```bash
801
- ➜ ~  export REXE_OPTIONS=-op
802
- ➜ ~  rexe '2 * 7'
801
+ $ export REXE_OPTIONS=-op
802
+ $ rexe '2 * 7'
803
803
  14
804
804
  ```
805
805
 
@@ -808,10 +808,10 @@ Of course, if you put the `-op` in the `REXE_OPTIONS` environment variable, you
808
808
 
809
809
  #### Outputting ENV
810
810
 
811
- Output the contents of `ENV` using AwesomePrint [see footnote ^4 regarding ENV.to_s]:
811
+ Output the contents of `ENV` using AmazingPrint [see footnote ^4 regarding ENV.to_s]:
812
812
 
813
813
  ```bash
814
- ➜ ~  rexe -oa ENV
814
+ $ rexe -oa ENV
815
815
  ```
816
816
  ```
817
817
  {
@@ -830,7 +830,7 @@ Output the contents of `ENV` using AwesomePrint [see footnote ^4 regarding ENV.t
830
830
  Show disk space used/free on a Mac's main hard drive's main partition:
831
831
 
832
832
  ```bash
833
- ➜ ~  df -h | grep disk1s1 | rexe -ml \
833
+ $ df -h | grep disk1s1 | rexe -ml \
834
834
  "x = split; puts %Q{#{x[4]} Used: #{x[2]}, Avail: #{x[3]}}"
835
835
  91% Used: 412Gi, Avail: 44Gi
836
836
  ```
@@ -844,7 +844,7 @@ Show disk space used/free on a Mac's main hard drive's main partition:
844
844
  Show the 3 longest file names of the current directory, with their lengths, in descending order:
845
845
 
846
846
  ```bash
847
- ➜ ~  ls | rexe -ml -op "%Q{[%4d] %s} % [length, self]" | sort -r | head -3
847
+ $ ls | rexe -ml -op "%Q{[%4d] %s} % [length, self]" | sort -r | head -3
848
848
  [ 50] Agoda_Booking_ID_9999999 49_–_RECEIPT_enclosed.pdf
849
849
  [ 40] 679a5c034994544aab4635ecbd50ab73-big.jpg
850
850
  [ 28] 2018-abc-2019-01-16-2340.zip
@@ -859,11 +859,11 @@ When you right align numbers using printf formatting, sorting the lines alphabet
859
859
  This uses an [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) to output text to the terminal in yellow:
860
860
 
861
861
  ```bash
862
- ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m}; puts to_a"
863
- ➜ ~  # or
864
- ➜ ~  cowsay hello | rexe -mb "print %Q{\u001b[33m}; puts self"
865
- ➜ ~  # or
866
- ➜ ~  cowsay hello | rexe "print %Q{\u001b[33m}; puts STDIN.read"
862
+ $ cowsay hello | rexe -me "print %Q{\u001b[33m}; puts to_a"
863
+ $ # or
864
+ $ cowsay hello | rexe -mb "print %Q{\u001b[33m}; puts self"
865
+ $ # or
866
+ $ cowsay hello | rexe "print %Q{\u001b[33m}; puts STDIN.read"
867
867
  ```
868
868
  ```
869
869
  _______
@@ -912,13 +912,13 @@ end
912
912
  Then when we issue a command that succeeds, the Hallelujah Chorus is played [see footnote ^2]:
913
913
 
914
914
  ```bash
915
- ➜ ~  uname; echo $? | rexe play_result_by_exit_code
915
+ $ uname; echo $? | rexe play_result_by_exit_code
916
916
  ```
917
917
 
918
918
  ...but when the command fails, in this case, with an executable which is not found, it plays Rick Astley's "Never Gonna Give You Up":
919
919
 
920
920
  ```bash
921
- ➜ ~  uuuuu; echo $? | rexe play_result_by_exit_code
921
+ $ uuuuu; echo $? | rexe play_result_by_exit_code
922
922
  ```
923
923
 
924
924
  ----
@@ -940,7 +940,7 @@ Another formatting example...I wanted to reformat this source code...
940
940
  ...into something more suitable for my help text. Admittedly, the time it took to do this with rexe probably exceeded the time to do it manually, but it was an interesting exercise and made it easy to try different formats. Here it is, after copying the original text to the clipboard:
941
941
 
942
942
  ```bash
943
- ➜ ~  pbpaste | rexe -ml -op "sub(%q{'}, '-o').sub(%q{' =>}, %q{ })"
943
+ $ pbpaste | rexe -ml -op "sub(%q{'}, '-o').sub(%q{' =>}, %q{ })"
944
944
  -oi Inspect
945
945
  -oj JSON
946
946
  -oJ Pretty JSON
@@ -997,7 +997,7 @@ lib/rock_books/documents/journal_entry.rb:
997
997
  So this is what worked well for me:
998
998
 
999
999
  ```bash
1000
- ➜ ~  grep Struct **/*.rb | grep -v OpenStruct | rexe -ml -op \
1000
+ $ grep Struct **/*.rb | grep -v OpenStruct | rexe -ml -op \
1001
1001
  "a = \
1002
1002
  gsub('lib/rock_books/', '') \
1003
1003
  .gsub('< Struct.new', '') \
data/exe/rexe CHANGED
@@ -15,7 +15,7 @@ require 'shellwords'
15
15
 
16
16
  class Rexe
17
17
 
18
- VERSION = '1.4.1'
18
+ VERSION = '1.5.0'
19
19
 
20
20
  PROJECT_URL = 'https://github.com/keithrbennett/rexe'
21
21
 
@@ -107,7 +107,7 @@ class Rexe
107
107
 
108
108
  def output_formats
109
109
  @output_formats ||= {
110
- 'a' => :awesome_print,
110
+ 'a' => :amazing_print,
111
111
  'i' => :inspect,
112
112
  'j' => :json,
113
113
  'J' => :pretty_json,
@@ -123,7 +123,7 @@ class Rexe
123
123
 
124
124
  def formatters
125
125
  @formatters ||= {
126
- awesome_print: ->(obj) { obj.ai << "\n" },
126
+ amazing_print: ->(obj) { obj.ai << "\n" },
127
127
  inspect: ->(obj) { obj.inspect + "\n" },
128
128
  json: ->(obj) { obj.to_json },
129
129
  marshal: ->(obj) { Marshal.dump(obj) },
@@ -141,7 +141,7 @@ class Rexe
141
141
  @format_requires ||= {
142
142
  json: 'json',
143
143
  pretty_json: 'json',
144
- awesome_print: 'awesome_print',
144
+ amazing_print: 'amazing_print',
145
145
  pretty_print: 'pp',
146
146
  yaml: 'yaml'
147
147
  }
@@ -217,7 +217,7 @@ class Rexe
217
217
  -n, --[no-]noop Do not execute the code (useful with -g);
218
218
  For true: yes, true, y, +; for false: no, false, n
219
219
  -o, --output_format FORMAT Output format, defaults to -on (no output):
220
- -oa Awesome Print
220
+ -oa Amazing Print
221
221
  -oi Inspect
222
222
  -oj JSON
223
223
  -oJ Pretty JSON
@@ -245,7 +245,7 @@ class Rexe
245
245
 
246
246
  If there is a REXE_OPTIONS environment variable, its content will be prepended
247
247
  to the command line so that you can specify options implicitly
248
- (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
248
+ (e.g. `export REXE_OPTIONS="-r amazing_print,yaml"`)
249
249
 
250
250
  HEREDOC
251
251
 
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
39
  spec.require_paths = ["lib"]
40
40
 
41
- spec.add_dependency "awesome_print"
41
+ spec.add_dependency "amazing_print"
42
42
 
43
43
  spec.add_development_dependency "bundler", "~> 2.0"
44
44
  spec.add_development_dependency "os"
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.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: 2020-04-29 00:00:00.000000000 Z
11
+ date: 2020-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: awesome_print
14
+ name: amazing_print
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.8
128
+ rubygems_version: 3.1.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Ruby Command Line Executor