From 41700ad112d7ee7d7ddb5579929ddfaf91bbcaef Mon Sep 17 00:00:00 2001 From: Kevin Ernst Date: Sun, 12 Nov 2023 09:09:54 -0500 Subject: [PATCH 1/2] Support reading from stdin with `-f -` (or no args) --- webtable_to_text.rb | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/webtable_to_text.rb b/webtable_to_text.rb index ef90d52..dde87dd 100755 --- a/webtable_to_text.rb +++ b/webtable_to_text.rb @@ -11,12 +11,19 @@ options = {} OptionParser.new do |opts| - opts.banner = " Usage: webtable_to_text.rb [options]" + opts.banner = < Date: Sun, 12 Nov 2023 09:19:33 -0500 Subject: [PATCH 2/2] Print help if no filename and stdin isn't a pipe --- webtable_to_text.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webtable_to_text.rb b/webtable_to_text.rb index dde87dd..d23b74a 100755 --- a/webtable_to_text.rb +++ b/webtable_to_text.rb @@ -50,7 +50,13 @@ source_content = File.read(file) end else - #abort(" Please provide a source file or URL as input") + if $stdin.isatty + abort(" Please provide a source file or URL as input. See '--help'.") + end + if options[:interactive] + abort(" Interactive mode not supported when reading from a pipe.") + end + source_location = '(stdin)' source_content = ARGF.read end @@ -60,7 +66,7 @@ len = tables.length if len < 1 - abort(" No tables found in page at #{source_location}") + abort(" No tables found in page at #{source_location}.") end numstring = "all"