Class: Fluent::Auditify::Command::Auditify
- Inherits:
-
Object
- Object
- Fluent::Auditify::Command::Auditify
- Defined in:
- lib/fluent/auditify/command/auditify.rb
Instance Method Summary collapse
-
#initialize ⇒ Auditify
constructor
A new instance of Auditify.
- #run(argv) ⇒ Object
Constructor Details
#initialize ⇒ Auditify
Returns a new instance of Auditify.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluent/auditify/command/auditify.rb', line 12 def initialize @parser = OptionParser.new @parser. = "Usage: fluent-auditify [options]" @parser.version = Fluent::Auditify::VERSION = { verbose: false, syntax_check: true, upgrade_config: :v1, config: "fluentd.conf", log_level: Logger::INFO, color: true, fluentd_version: :auto, config_version: :v1, mask_only: false } @parser.on('-u [CONFIG_VERSION]', '--upgrade-config [CONFIG_VERSION]', "Upgrade Fluentd configuration to CONFIG_VERSION (default: v1)", :v1) { |v| unless v # assume v1 by default else unless %w(v1).include?(v) puts "ERROR: The value of -u CONFIG_VERSION must be v1" exit 1 end [:upgrade_config] = v.intern end } @parser.on('-s', '--syntax-check', "Enable syntax check", TrueClass) { |v| [:syntax_check] = v } @parser.on('-c CONFIG_FILE', '--config CONFIG_FILE', "Specify configuration file") { |v| [:config] = v } @parser.on('-v', '--[no-]verbose', "Run verbosely") { |v| [:verbose] = v } @parser.on('--fluentd-version VERSION', "Specify Fluentd version (default: auto)") { |v| [:fluentd_version] = v } @parser.on('--log-level LOG_LEVEL', "Specify log level (default: INFO)") { |v| [:log_level] = Fluent::Auditify::Log.to_logger_level(v) } @parser.on('--report-format FORMAT', "Simplify format in error. (default: auto)") { |v| [:reporter] = Fluent::Auditify::Reporter.to_report_format(v) } @parser.on('--config-version VERSION', "Simplify Fluentd configuration version. (default: auto)") { |v| unless %w(v0 v1).include?(v) puts Pastel.new.bright_red.on_black('ERROR') + ": The value of --config-version CONFIG_VERSION must be v0 or v1" exit 1 end [:config_version] = v.intern } @parser.on('--mask-only', "Run in mask mode") { |v| [:mask_only] = v } end |
Instance Method Details
#run(argv) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fluent/auditify/command/auditify.rb', line 74 def run(argv) begin @parser.parse!(argv) rescue OptionParser::ParseError, OptionParser::InvalidOption => e puts Pastel.new.bright_red.on_black('ERROR') + ": fluent-auditify: #{e.message}" return false end if [:syntax_check] opts = { color: [:color], log_level: [:log_level] } runner = Fluent::Auditify::SyntaxChecker.new() return runner.run() elsif [:upgrade_config] end true end |