Sha256: 860bcb3a5c45cdbc3bc9025bee024f9ee07f998d38ffce7c71d41a02d178d647
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
#!/usr/bin/ruby =begin Usage: atom-show [options] source displays a feed human-readably 'source' can be a path on the local filesystem, the URL of an Atom Collection or '-' for stdin. =end require 'atom/tools' include Atom::Tools def parse_options options = { } opts = OptionParser.new do |opts| opts.banner = <<END Usage: #{$0} [options] [source] displays a feed human-readably 'source' can be a path on the local filesystem, the URL of an Atom Collection or '-' for stdin. END opts.on('-c', '--complete', "Follow previous and next links in the source feed to obtain the entire logical feed") do options[:complete] = true end opts.on('-n', '--content [MAX-LENGTH]', "Display max-length words of each entry's content") do |length| options[:content] = length ? length.to_i : 0 end atom_options opts, options end opts.parse!(ARGV) if ARGV.length > 1 puts opts exit end options end if __FILE__ == $0 require 'optparse' options = parse_options source = ARGV[0] source ||= '-' entries = parse_input source, options entries.each do |e| puts e.title if options[:content] if options[:content].zero? puts e.content.to_s else puts e.content.to_s.split(' ')[0,options[:content]].join(' ') end end puts end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
atom-tools-2.0.1 | bin/atom-show |