class Doctl < Formula desc "Command-line tool for DigitalOcean" homepage "https://github.com/digitalocean/doctl" url "https://github.com/digitalocean/doctl/archive/v1.29.3.tar.gz" sha256 "1420439c1dc9f1b087dec0a57b5791bffa9947aa9f9c54267136f3683f3e1d6e" head "https://github.com/digitalocean/doctl.git" bottle do cellar :any_skip_relocation sha256 "5cb51c817a289f5b23608e34a57adbe3e4abb1b672472108ed87ee64d05148c3" => :mojave sha256 "7b0ba9e0739b842f6777e8206a4673541531afc75921bbf91b5b17fc4f7e2057" => :high_sierra sha256 "be7b291b563baa41124411d112b4941ad59ba9594528217698a4d495359478b1" => :sierra end depends_on "go" => :build def install ENV["GO111MODULE"] = "on" 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