Class: Html2rss::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/html2rss/cli.rb

Overview

The Html2rss command line interface.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/html2rss/cli.rb', line 15

def self.exit_on_failure?
  true
end

Instance Method Details

#auto(url) ⇒ Object



35
36
37
# File 'lib/html2rss/cli.rb', line 35

def auto(url)
  puts Html2rss.auto_source(url)
end

#feed(yaml_file, *options) ⇒ nil

Prints the feed to STDOUT.

Parameters:

  • yaml_file (String)

    Path to the YAML configuration file.

  • options (Array<String>)

    Additional options including feed name and parameters.

Returns:

  • (nil)


26
27
28
29
30
31
32
# File 'lib/html2rss/cli.rb', line 26

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