class Ncdu < Formula bottle do root_url "https://homebrew.hyprnet/bottles" sha256 cellar: :any, arm64_sequoia: "d56b0ffa80c15fa5758a8b7b59525687a1a04ce043d540936b6db917c7c14c30" sha256 cellar: :any, arm64_tahoe: "9a08dd709b18d87d90b016b8685d56f2de8d537e437ab44cf4ed92203df7a245" sha256 cellar: :any_skip_relocation, x86_64_linux: "762c13f508d0699c363f0a3a0741a19cbd14d1ef8a86fdd1d70aeaaf2f7bd851" end desc "NCurses Disk Usage" homepage "https://dev.yorhel.nl/ncdu" url "https://dev.yorhel.nl/download/ncdu-2.9.2.tar.gz" sha256 "e91135281cb66569f2ca4c0bac277246991e7e52524c0ca8cba3de5c8e81cec9" license "MIT" head "https://g.blicky.net/ncdu.git", branch: "zig" livecheck do url :homepage regex(/href=.*?ncdu[._-]v?(\d+(?:\.\d+)+)\.t/i) end depends_on "pkgconf" => :build depends_on "zig@0.15" => :build # Without this, `ncdu` is unusable when `TERM=tmux-256color`. depends_on "ncurses" depends_on "zstd" def install args = [] args << "-Dpie=true" if OS.mac? # Workaround for https://github.com/Homebrew/homebrew-core/pull/141453#discussion_r1320821081 # Remove this workaround when the same is removed in `zig.rb`. if OS.linux? ENV["NIX_LDFLAGS"] = ENV["HOMEBREW_RPATH_PATHS"].split(":") .map { |p| "-rpath #{p}" } .join(" ") end # Avoid the Makefile for now so that we can pass `-Dcpu` to `zig build`. # https://code.blicky.net/yorhel/ncdu/issues/185 system "zig", "build", *args, *std_zig_args man1.install "ncdu.1" end test do assert_match version.to_s, shell_output("#{bin}/ncdu -v") system bin/"ncdu", "-o", "test" output = JSON.parse((testpath/"test").read) assert_equal "ncdu", output[2]["progname"] assert_equal version.to_s, output[2]["progver"] assert_equal Pathname.pwd.size, output[3][0]["asize"] end end