class Doctl < Formula desc "Command-line tool for DigitalOcean" homepage "https://github.com/digitalocean/doctl" url "https://github.com/digitalocean/doctl/archive/v1.32.3.tar.gz" sha256 "e6e60c3bd6c3638a71e7be610c662344bca240194cc3de826e78a51739ca546d" revision 1 head "https://github.com/digitalocean/doctl.git" bottle do cellar :any_skip_relocation sha256 "cfc7ef38d92976ec2b2d4cfdda29eed709c1a82c32366d98b00428cf3248a0fc" => :catalina sha256 "92908f6a0afa5a6c6a3372a7f70c75fef606a091d649ebbc3cf93096ff01ddca" => :mojave sha256 "4efa4bed0f2f354d1aef4f9252464a0bde0fe17953de5068ec202da01c0b745b" => :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