homebrew-core/Formula/broot.rb

59 lines
2.2 KiB
Ruby

class Broot < Formula
desc "New way to see and navigate directory trees"
homepage "https://dystroy.org/broot/"
url "https://github.com/Canop/broot/archive/v1.4.0.tar.gz"
sha256 "410c948b5a45796238efacac857a74594511e24615399e604795d17efbda0461"
license "MIT"
head "https://github.com/Canop/broot.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "ea02f6ccb6e1680d24003fbea5c701f600c161dd726f7c0b9f4f75e1e9e4ceb1"
sha256 cellar: :any_skip_relocation, big_sur: "723b5d1d13a005de6e45a9753541a3da10f6e068261274ac917d7bc1353fd399"
sha256 cellar: :any_skip_relocation, catalina: "3baf8b2baa2fea41638564bf9c3c0f3bc710ca696af5d7b7c0274898d10a1897"
sha256 cellar: :any_skip_relocation, mojave: "e819f775427920dc03495990a1c052ef600ef498d9e72edba9b777e7f084dbbe"
end
depends_on "rust" => :build
uses_from_macos "zlib"
def install
system "cargo", "install", *std_cargo_args
# Replace man page "#version" and "#date" based on logic in release.sh
inreplace "man/page" do |s|
s.gsub! "#version", version
s.gsub! "#date", Time.now.utc.strftime("%Y/%m/%d")
end
man1.install "man/page" => "broot.1"
# Completion scripts are generated in the crate's build directory,
# which includes a fingerprint hash. Try to locate it first
out_dir = Dir["target/release/build/broot-*/out"].first
bash_completion.install "#{out_dir}/broot.bash"
bash_completion.install "#{out_dir}/br.bash"
fish_completion.install "#{out_dir}/broot.fish"
fish_completion.install "#{out_dir}/br.fish"
zsh_completion.install "#{out_dir}/_broot"
zsh_completion.install "#{out_dir}/_br"
end
test do
on_linux do
return if ENV["HOMEBREW_GITHUB_ACTIONS"]
end
assert_match "A tree explorer and a customizable launcher", shell_output("#{bin}/broot --help 2>&1")
require "pty"
require "io/console"
PTY.spawn(bin/"broot", "--cmd", ":pt", "--no-style", "--out", testpath/"output.txt", err: :out) do |r, w, pid|
r.winsize = [20, 80] # broot dependency termimad requires width > 2
w.write "n\r"
assert_match "New Configuration file written in", r.read
Process.wait(pid)
end
assert_equal 0, $CHILD_STATUS.exitstatus
end
end