Sha256: 00f572f2fc1b586d91db7c9028d65aa90d5085e7936b62eb06d659596c3c0b14

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require_relative '../html2rss'
require 'thor'
require 'addressable'

##
# The Html2rss namespace / command line interface.
module Html2rss
  Log = Logger.new($stderr)

  ##
  # The Html2rss command line interface.
  class CLI < Thor
    def self.exit_on_failure?
      true
    end

    desc 'feed YAML_FILE [FEED_NAME] [param=value ...]', 'Print RSS built from the YAML_FILE file to stdout'
    ##
    # Prints the feed to STDOUT.
    #
    # @param yaml_file [String] Path to the YAML configuration file.
    # @param options [Array<String>] Additional options including feed name and parameters.
    # @return [nil]
    def feed(yaml_file, *options)
      raise "File '#{yaml_file}' does not exist" unless File.exist?(yaml_file)

      feed_name = options.shift
      params = options.to_h { |opt| opt.split('=', 2) }
      puts Html2rss.feed_from_yaml_config(yaml_file, feed_name, params:)
    end

    desc 'auto URL', 'automatically sources an RSS feed from the URL'
    def auto(url)
      puts Html2rss.auto_source(url)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
html2rss-0.15.0 lib/html2rss/cli.rb
html2rss-0.14.0 lib/html2rss/cli.rb
html2rss-0.13.0 lib/html2rss/cli.rb