summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Terceiro <terceiro@softwarelivre.org>2014-02-13 16:47:57 -0300
committerAntonio Terceiro <terceiro@softwarelivre.org>2014-02-13 16:47:57 -0300
commit471837eb27f37a736020f39f64e69a85305ae71d (patch)
treea6fa144ce2d352a5d9a193e72274a5aed55f4ffa
parent240400360e15da0614b37b945983611fa48975d9 (diff)
downloadfeed2imap-471837eb27f37a736020f39f64e69a85305ae71d.tar.gz
feed2imap-471837eb27f37a736020f39f64e69a85305ae71d.tar.bz2
feed2imap-471837eb27f37a736020f39f64e69a85305ae71d.zip
feed2imap-test: can now take a feed URL as argument
-rwxr-xr-xfeed2imap-test25
1 files changed, 22 insertions, 3 deletions
diff --git a/feed2imap-test b/feed2imap-test
index b976bea..3216d88 100755
--- a/feed2imap-test
+++ b/feed2imap-test
@@ -16,7 +16,10 @@ FileUtils.mkdir_p(File.join(maildir, 'cur'))
FileUtils.mkdir_p(File.join(maildir, 'tmp'))
cache = File.join(tmp, 'cache')
-config_data = <<EOF
+
+case ARGV.length
+when 0
+ config_data = <<EOF
cache: #{cache}
feeds:
- name: CNPQ
@@ -26,15 +29,31 @@ feeds:
url: http://www.xkcd.com/atom.xml
target: maildir://#{maildir}
EOF
+when 1
+ config_data = <<EOF
+cache: #{cache}
+feeds:
+ - name: Test
+ url: #{ARGV.first}
+ target: maildir://#{maildir}
+EOF
+else
+ puts("usage: %s [FEED]" % $PROGRAM_NAME)
+ exit(1)
+end
+
config = File.join(tmp, 'feed2imap.yaml')
File.open(config, 'w') do |f|
f.write(config_data)
end
-system('ruby', "-I#{base}/lib", "#{base}/bin/feed2imap", '--config', config, '--verbose') || exit(1)
+unless system('ruby', "-I#{base}/lib", "#{base}/bin/feed2imap", '--config', config, '--verbose')
+ puts("E: feed2imap failed")
+ exit(1)
+end
print "Open target maildir with mutt? [Y/n]"
-response = gets.strip
+response = $stdin.gets.strip
if response.downcase == 'y' || response == ''
exec('mutt', '-f', maildir)
end