class Doctl < Formula desc "Command-line tool for DigitalOcean" homepage "https://github.com/digitalocean/doctl" url "https://github.com/digitalocean/doctl/archive/v1.20.1.tar.gz" sha256 "bfd0209ab6a10ace41d17608f546a19e806c92f818be2ed0d4bfe8ab256c8a69" head "https://github.com/digitalocean/doctl.git" bottle do cellar :any_skip_relocation sha256 "e2603bd9b06b457cc0eeeb67f7494905f0bf38f374fff57d642b0e5f904429ab" => :mojave sha256 "da6eee82c2a84c43dfe2a2b735f55c63a6a7fa24c62fdc4c69b2ca0c46b6911f" => :high_sierra sha256 "53c610ce1d04ca99562760d6fc42c9e105698a11ea57d4a489f9f0f00cf148eb" => :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