Sha256: 22a7b15c8914aeb3e264e2015a422c6984b322cb651d753188c03ae7f896036c

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Commands
    module Initialization
      include Mixins::Rule

      def self.included(thor)
        thor.class_eval do
          desc "rule", "Create a rule file"
          method_option :filename, type: :string, default: "rule.yml"
          def rule
            filename = options["filename"]

            warning = "#{filename} exists. Do you want to overwrite it? (y/n)"
            if File.exist?(filename) && !(yes? warning)
              return
            end

            initialize_rule_yaml filename

            puts "The rule file is initialized as #{filename}.".colorize(:blue)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-4.1.2 lib/mihari/commands/init.rb
mihari-4.1.1 lib/mihari/commands/init.rb
mihari-4.1.0 lib/mihari/commands/init.rb
mihari-4.0.0 lib/mihari/commands/init.rb