class Doctl < Formula desc "Command-line tool for DigitalOcean" homepage "https://github.com/digitalocean/doctl" url "https://github.com/digitalocean/doctl/archive/v1.20.0.tar.gz" sha256 "2be072166558f06b86c294940485e815d469204386534a341dde8215b9559c2a" head "https://github.com/digitalocean/doctl.git" bottle do cellar :any_skip_relocation sha256 "091f23cb84f0799f64a20a6ee4d2fa30a91cd1e60e1153ad5f56dd982183f596" => :mojave sha256 "7ddf06780a37c0279a820bcdd46e9766dccc2352ad29db2eb2386c7f8901f5f3" => :high_sierra sha256 "47d4cce8b5ca13cc1632b858dce964b45ff1b801e703de326678a4c5312a157b" => :sierra end depends_on "go" => :build def install ENV["GOPATH"] = buildpath mkdir_p buildpath/"src/github.com/digitalocean/" ln_sf buildpath, buildpath/"src/github.com/digitalocean/doctl" doctl_version = version.to_s.split(/\./) 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, "github.com/digitalocean/doctl/cmd/doctl" bin.install "doctl" (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