Sha256: e1db58443af61f16d79acb9aeefee10a7ebc8b991f6af4028a91ca6ef231440f

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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
        $stderr.puts "#{e.class} #{e.message} #{e.backtrace.first}"
        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
        $stderr.puts "#{e.class} #{e.message} #{e.backtrace.first}"
        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.2 lib/fluent/format/cli.rb