Sha256: f2d65b3ca802c068a157e757382f6a99558916e3aaee01c78ad5c3a29ff980a1

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'rack'
require 'thor'

module Weneedfeed
  class Command < ::Thor
    class << self
      # @note Override for thor breaking change.
      #   See https://github.com/erikhuda/thor/issues/244.
      def exit_on_failure?
        true
      end
    end

    desc(
      'build',
      'Build static files.'
    )

    method_option(
      :base_url,
      desc: 'Base URL where to locate built files. (e.g. `"https://user.github.io/repo"`)',
      required: true,
      type: :string
    )

    method_option(
      :schema_path,
      default: 'weneedfeed.yml',
      desc: 'Path to weneedfeed YAML schema file.',
      type: :string
    )

    # @param [String] base_url
    # @param [String] schema_path
    def build
      ::Weneedfeed::Capture.call(
        base_url: options[:base_url],
        schema_path: options[:schema_path]
      )
    end

    desc(
      'server',
      'Run HTTP server.'
    )

    method_option(
      :schema_path,
      default: 'weneedfeed.yml',
      desc: 'Path to weneedfeed YAML schema file.',
      type: :string
    )

    def server
      application = Weneedfeed::Application.new(schema_path: options[:schema_path])
      ::Rack::Handler.default.run(application)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
weneedfeed-0.17.0 lib/weneedfeed/command.rb
weneedfeed-0.16.1 lib/weneedfeed/command.rb
weneedfeed-0.16.0 lib/weneedfeed/command.rb
weneedfeed-0.15.0 lib/weneedfeed/command.rb
weneedfeed-0.14.0 lib/weneedfeed/command.rb