# typed: false
# frozen_string_literal: true

# This file was generated by GoReleaser. DO NOT EDIT.
class Mactop < Formula
  desc "Apple Silicon Monitor Top written in Go Lang"
  homepage "https://github.com/metaspartan/mactop"
  version "2.1.4"

  depends_on "macos"
  depends_on :macos

  if Hardware::CPU.arm?
    url "https://github.com/metaspartan/mactop/releases/download/v2.1.4/mactop_2.1.4_darwin_arm64.tar.gz"
    sha256 "a903fe13e23d570ae4d36efef3279b76db9126dc1414780c7dd06a896fb485d4"

    define_method(:install) do
      bin.install "mactop"
    end
  end

  def caveats
    <<~EOS
      mactop requires macOS 12+, and runs exclusively on Apple Silicon.

      To run mactop as a background service:
        brew services start mactop

      To view service error logs:
        brew services logs mactop

      Prometheus metrics will be available at:
        http://localhost:9101/metrics

      To change the Prometheus port:
        1. brew services stop mactop
        2. brew services edit mactop
        3. Change 9101 to your desired port
        4. brew services start mactop

      Or run manually with a custom port:
        mactop -p <PORT> --headless
    EOS
  end

  service do
    run [opt_bin/"mactop", "-p", "9101", "--headless"]
    keep_alive true
    log_path var/"log/mactop.log"
    error_log_path var/"log/mactop.error.log"
    process_type :background
    nice 10
  end
end
