rexe 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -1
  4. data/exe/rexe +37 -8
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7477c149efa64d0b00e4127d5219546c7ef1559fb7708ca8b389a9ef48c7348
4
- data.tar.gz: 76114118d28be5a81561f8c67af9727fca5201a5ca443d0cdc6d60f5431451a1
3
+ metadata.gz: ab6cd585e21edba16a3a5c8a8891e476ec637439d7ad138f4bd3100eb7612dd9
4
+ data.tar.gz: a5726d9c8796bbe3cba5ce72d29fc47baf1a424a88ee9ee85ddc437e07a659ec
5
5
  SHA512:
6
- metadata.gz: 615ff910e6a79cdc38b574503253871e5141bf027f6753aaa2375a4b8e2a4108f2ebdd6eb4532dbd46daf655212ac8f6583b538f103164abcc1264e84ae71450
7
- data.tar.gz: 6cd017a263416d521de4c1a8b55cdba5fb55605a053d3bb39e019c1521f19c1549eeed715cc9c8c37e90dbe7109681a27de56ee8ef6e53ffa41c337ebd2fb29a
6
+ metadata.gz: 4ed213f525f937ed0c5a34d0731e4e4373a47d1aa185fa98a6478f73946009afbd91fc50241b6e2ca2aadd377ee1b6d1d812cf3c0f79a7e19d6219d5856aa6ce
7
+ data.tar.gz: 33772f5dbe83863c18405950cfd84b128a36a8733f7a459221f74cfce1ed7d076bd8b3f815f221b05efc0386ad2b59c4a65e8e3842f412cebfeb91516fa876b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## rexe -- Ruby Command Line Executor/Filter
2
2
 
3
+ ### 1.6.0
4
+
5
+ * Replace calls to `exists?`, which has been removed, with `exist?`.
6
+ * Add warning messages to stderr for unspecified options (input/output format, input mode),
7
+ but only when logging is disabled.
8
+
9
+ ### 1.5.1
10
+
11
+ * Change string concatenations using << to creation of new strings with += to accommodate default-frozen strings.
12
+
13
+
3
14
  ### 1.5.0
4
15
 
5
16
  * Switch from AwesomePrint to AmazingPrint, and change all references in text, help, etc.
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.5.0 -- https://github.com/keithrbennett/rexe
76
+ rexe -- Ruby Command Line Executor/Filter -- v1.6.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,
data/exe/rexe CHANGED
@@ -15,7 +15,7 @@ require 'shellwords'
15
15
 
16
16
  class Rexe
17
17
 
18
- VERSION = '1.5.0'
18
+ VERSION = '1.6.0'
19
19
 
20
20
  PROJECT_URL = 'https://github.com/keithrbennett/rexe'
21
21
 
@@ -57,7 +57,7 @@ class Rexe
57
57
 
58
58
 
59
59
  def clear
60
- self.input_filespec = nil
60
+ self.input_filespec = nil
61
61
  self.input_format = :none
62
62
  self.input_mode = :none
63
63
  self.output_format = :none
@@ -123,7 +123,7 @@ class Rexe
123
123
 
124
124
  def formatters
125
125
  @formatters ||= {
126
- amazing_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) },
@@ -247,7 +247,7 @@ class Rexe
247
247
  to the command line so that you can specify options implicitly
248
248
  (e.g. `export REXE_OPTIONS="-r amazing_print,yaml"`)
249
249
 
250
- HEREDOC
250
+ HEREDOC
251
251
 
252
252
  @help_text.freeze
253
253
  end
@@ -289,6 +289,29 @@ class Rexe
289
289
 
290
290
  prepend_environment_options
291
291
 
292
+ input_mode_specified = false
293
+ input_format_specified = false
294
+ output_format_specified = false
295
+
296
+ report_unspecified_options = ->() do
297
+ messages = []
298
+
299
+ unless input_mode_specified
300
+ messages << 'Input mode not specified. Defaulting to -mn (none).'
301
+ end
302
+ unless input_format_specified
303
+ messages << 'Input format not specified. Defaulting to -in (none).'
304
+ end
305
+ unless output_format_specified
306
+ messages << 'Output mode not specified. Defaulting to -on (none).'
307
+ end
308
+
309
+ if messages.any?
310
+ $stderr.puts("#{messages.join("\n")}")
311
+ $stderr.puts("See help (run with -h) for more information.\n\n")
312
+ end
313
+ end
314
+
292
315
  OptionParser.new do |parser|
293
316
 
294
317
  parser.on('-c', '--clear_options', "Clear all previous command line options") do |v|
@@ -302,8 +325,10 @@ class Rexe
302
325
  end
303
326
  options.input_filespec = v
304
327
  options.input_format = autodetect_file_format(v)
328
+ input_format_specified = true
305
329
  if [:json, :yaml].include?(options.input_format)
306
330
  options.input_mode = :one_big_string
331
+ input_mode_specified = true
307
332
  end
308
333
  end
309
334
 
@@ -326,6 +351,7 @@ class Rexe
326
351
  if options.input_format.nil?
327
352
  raise("Input mode was '#{v}' but must be one of #{lookups.input_formats.keys}.")
328
353
  end
354
+ input_format_specified = true
329
355
  end
330
356
 
331
357
  parser.on('-l', '--load RUBY_FILE(S)', 'Ruby file(s) to load, comma separated, or ! to clear') do |v|
@@ -335,7 +361,7 @@ class Rexe
335
361
  loadfiles = v.split(',').map(&:strip).map { |s| File.expand_path(s) }
336
362
  removes, adds = loadfiles.partition { |filespec| filespec[0] == '-' }
337
363
 
338
- existent, nonexistent = adds.partition { |filespec| File.exists?(filespec) }
364
+ existent, nonexistent = adds.partition { |filespec| File.exist?(filespec) }
339
365
  if nonexistent.any?
340
366
  raise("\nDid not find the following files to load: #{nonexistent}\n\n")
341
367
  else
@@ -353,6 +379,7 @@ class Rexe
353
379
  if options.input_mode.nil?
354
380
  raise("Input mode was '#{v}' but must be one of #{lookups.input_modes.keys}.")
355
381
  end
382
+ input_mode_specified = true
356
383
  end
357
384
 
358
385
  # See https://stackoverflow.com/questions/54576873/ruby-optionparser-short-code-for-boolean-option
@@ -371,6 +398,7 @@ class Rexe
371
398
  if [options.output_format_tty, options.output_format_block].include?(nil)
372
399
  raise("Bad output mode '#{v}'; each must be one of #{lookups.output_formats.keys}.")
373
400
  end
401
+ output_format_specified = true
374
402
  end
375
403
 
376
404
  parser.on('-r', '--require REQUIRE(S)',
@@ -413,6 +441,7 @@ class Rexe
413
441
  options.requires = options.requires.sort.uniq
414
442
  options.loads.uniq!
415
443
 
444
+ report_unspecified_options.() if options.log_format == :none
416
445
  options
417
446
 
418
447
  end
@@ -436,7 +465,7 @@ class Rexe
436
465
 
437
466
  private def load_global_config_if_exists
438
467
  filespec = File.join(Dir.home, '.rexerc')
439
- load(filespec) if File.exists?(filespec)
468
+ load(filespec) if File.exist?(filespec)
440
469
  end
441
470
 
442
471
 
@@ -516,7 +545,7 @@ class Rexe
516
545
  raise error # re-raise the error, can't fix it
517
546
  else
518
547
  load_dir = File.dirname(gem_path)
519
- $LOAD_PATH << load_dir
548
+ $LOAD_PATH += load_dir
520
549
  require the_require
521
550
  end
522
551
  end
@@ -566,4 +595,4 @@ def bundler_run(&block)
566
595
  end
567
596
 
568
597
 
569
- bundler_run { Rexe::Main.new.call }
598
+ bundler_run { Rexe::Main.new.call }
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.5.0
4
+ version: 1.6.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-08-15 00:00:00.000000000 Z
11
+ date: 2023-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -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.1.2
128
+ rubygems_version: 3.4.1
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Ruby Command Line Executor