class Doctl < Formula desc "Command-line tool for DigitalOcean" homepage "https://github.com/digitalocean/doctl" url "https://github.com/digitalocean/doctl/archive/v1.34.0.tar.gz" sha256 "21dc7370b812989582012180d99d908b12192129149295db63faa7c234e0cc06" head "https://github.com/digitalocean/doctl.git" bottle do cellar :any_skip_relocation sha256 "07158b1290338cbd4ac75b6e802979b57065149e8276f115093e946445a8b965" => :catalina sha256 "fe9848231ab2d1a1db9e769211d62e7e936c2d405c6c0c68a1d1e1e5334997a5" => :mojave sha256 "ef07a00403432d55036283b41f6b574bcd2f98671efd10adf932d68d24e471e6" => :high_sierra end depends_on "go" => :build def install ENV["GOPATH"] = buildpath doctl_version = version.to_s.split(/\./) src = buildpath/"src/github.com/digitalocean/doctl" src.install buildpath.children src.cd do base_flag = "-X github.com/digitalocean/doctl" ldflags = %W[ #{base_flag}.Major=#{doctl_version[0]} #{base_flag}.Minor=#{doctl_version[1]} #{base_flag}.Patch=#{doctl_version[2]} #{base_flag}.Label=release ].join(" ") system "go", "build", "-ldflags", ldflags, "-o", bin/"doctl", "github.com/digitalocean/doctl/cmd/doctl" end (bash_completion/"doctl").write `#{bin}/doctl completion bash` (zsh_completion/"_doctl").write `#{bin}/doctl completion zsh` end test do assert_match "doctl version #{version}-release", shell_output("#{bin}/doctl version") end end