Sha256: 8b053122bc452c861866c626b7e5aad0333934d0bf24d53a74da30b09f2d1162

Contents?: true

Size: 967 Bytes

Versions: 5

Compression:

Stored size: 967 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]
            include Mixins

            desc "add [PATH]", "Add an alert"
            around :with_db_connection
            #
            # @param [String] path
            #
            def add(path)
              result = Dry::Monads::Try[StandardError] do
                # @type [Mihari::Services::AlertProxy]
                proxy = Mihari::Services::AlertBuilder.call(path)
                Mihari::Services::AlertRunner.call proxy
              end.to_result

              # @type [Mihari::Models::Alert]
              alert = result.value!
              data = Entities::Alert.represent(alert)
              puts JSON.pretty_generate(data.as_json)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/commands/alert.rb
mihari-6.2.0 lib/mihari/commands/alert.rb
mihari-6.1.0 lib/mihari/commands/alert.rb
mihari-6.0.0 lib/mihari/commands/alert.rb
mihari-5.7.2 lib/mihari/commands/alert.rb