Sha256: 02dc48a0cb54357662877d46534da16bf2338201a17c9482febe084d2ef2e54f

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Commands
    #
    # Alert sub-commands
    #
    module Alert
      class << self
        def included(thor)
          thor.class_eval do
            include Dry::Monads[:result, :try]

            desc "add [PATH]", "Add an alert"
            #
            # @param [String] path
            #
            def add(path)
              Mihari::Database.with_db_connection do
                builder = Services::AlertBuilder.new(path)

                runner_result_l = ->(proxy) { Services::AlertRunner.new(proxy).result }
                result = builder.result.bind(runner_result_l)

                alert = result.value!
                data = Entities::Alert.represent(alert)
                puts JSON.pretty_generate(data.as_json)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mihari-5.7.0 lib/mihari/commands/alert.rb