Sha256: cd1f9f1f8929d7ec93f831fd776e01ce9b5cb06cd5befa79518864e4a2c348cd

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 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
    )

    method_option(
      :port,
      default: '8080',
      desc: 'TCP port to bind to.',
      type: :string
    )

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
weneedfeed-0.20.0 lib/weneedfeed/command.rb
weneedfeed-0.19.3 lib/weneedfeed/command.rb
weneedfeed-0.19.2 lib/weneedfeed/command.rb
weneedfeed-0.19.1 lib/weneedfeed/command.rb
weneedfeed-0.19.0 lib/weneedfeed/command.rb
weneedfeed-0.18.0 lib/weneedfeed/command.rb