Sha256: 3f353b979e0b508ad56862b5dc7cd365738f48aa539e0dddebc27d24ce089773
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require "pathname" module Mihari module Commands module Initializer def self.included(thor) thor.class_eval do desc "init", "Initialize a new rule" method_option :path, type: :string, default: "./rule.yml" def init path = options["path"] warning = "#{path} exists. Do you want to overwrite it? (y/n)" return if Pathname(path).exist? && !(yes? warning) initialize_rule path Mihari.logger.info "A new rule is initialized as #{path}." end no_commands do # # @return [Mihari::Structs::Rule] # def rule_template Structs::Rule.from_path File.expand_path("../templates/rule.yml.erb", __dir__) end # # Create a new rule # # @param [String] path # @param [Dry::Files] files # # @return [nil] # def initialize_rule(path, files = Dry::Files.new) files.write(path, rule_template.yaml) end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.0.1 | lib/mihari/commands/initializer.rb |
mihari-5.0.0 | lib/mihari/commands/initializer.rb |