Sha256: 094526db9a9057b4ce3906ae8b79c54d9bbb373f953ae900a7a913b208d1baac

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'thor'
require_relative '../../fluent-format'

module Fluent
  class Format
    class CLI < Thor
      default_command :format
      desc "format", "Format fluent.conf"
      option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
      def format
        config = @options[:config]
        taputs Fluent::Format.format(config)
      rescue => e
        $log.error "#{e.class}: #{e}"
        exit 1
      end

      desc "check", "Check fluent.conf"
      option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
      option :plugin, :aliases => ["-p"], :type => :string, :desc => 'Fluentd plugin directory'
      def check
        config = @options[:config]
        plugin = @options[:plugin]
        Fluent::Format.check(config, plugin)
      rescue => e
        $log.error "#{e.class}: #{e}"
        exit 1
      end

      private

      def taputs(str)
        puts str
        str
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-format-0.2.1 lib/fluent/format/cli.rb