Skip to content

Commit

Permalink
Merge pull request #1839 from fluent/commands-show-version
Browse files Browse the repository at this point in the history
command: Show fluentd version for debug purpose
  • Loading branch information
repeatedly authored Feb 2, 2018
2 parents 29d4983 + 85a74a1 commit 24fd147
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/fluent/command/binlog_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require 'fluent/plugin'
require 'fluent/config/element'
require 'fluent/engine'
require 'fluent/version'

class FluentBinlogReader
SUBCOMMAND = %w(cat head formats)
Expand Down Expand Up @@ -49,7 +50,14 @@ def call

def command
command = @argv.shift
if !command || !SUBCOMMAND.include?(command)
if command
if command == '--version'
puts "#{File.basename($PROGRAM_NAME)} #{Fluent::VERSION}"
exit 0
elsif !SUBCOMMAND.include?(command)
usage "'#{command}' is not supported: Required subcommand : #{SUBCOMMAND.join(' | ')}"
end
else
usage "Required subcommand : #{SUBCOMMAND.join(' | ')}"
end

Expand All @@ -70,6 +78,7 @@ def initialize(argv = ARGV)

@options = { plugin: [] }
@opt_parser = OptionParser.new do |opt|
opt.version = Fluent::VERSION
opt.separator 'Options:'

opt.on('-p DIR', '--plugin', 'add library directory path') do |v|
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/command/ca_generate.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'openssl'
require 'optparse'
require 'fileutils'
require 'fluent/version'

module Fluent
class CaGenerate
Expand Down Expand Up @@ -145,6 +146,7 @@ def self.generate_self_signed_server_pair(opts={})

def configure_option_parser
@opt_parser.banner = HELP_TEXT
@opt_parser.version = Fluent::VERSION

@opt_parser.on('--key-length [KEY_LENGTH]',
"configure key length. (default: #{DEFAULT_OPTIONS[:private_key_length]})") do |v|
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
require 'fluent/env'
require 'fluent/time'
require 'fluent/msgpack_factory'
require 'fluent/version'

op = OptionParser.new

op.banner += " <tag>"
op.version = Fluent::VERSION

port = 24224
host = '127.0.0.1'
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/command/plugin_config_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require "fluent/engine"
require "fluent/system_config"
require "fluent/config/element"
require 'fluent/version'

class FluentPluginConfigFormatter

Expand Down Expand Up @@ -210,6 +211,7 @@ def usage(message = nil)

def prepare_option_parser
@parser = OptionParser.new
@parser.version = Fluent::VERSION
@parser.banner = <<BANNER
Usage: #{$0} [options] <type> <name>
Expand Down
2 changes: 2 additions & 0 deletions lib/fluent/command/plugin_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require "open-uri"

require "fluent/registry"
require 'fluent/version'

class FluentPluginGenerator
attr_reader :type, :name
Expand Down Expand Up @@ -91,6 +92,7 @@ def file(source, dest)

def prepare_parser
@parser = OptionParser.new
@parser.version = Fluent::VERSION
@parser.banner = <<BANNER
Usage: fluent-plugin-generate [options] <type> <name>
Expand Down

0 comments on commit 24fd147

Please sign in to comment.