homebrew-core/Formula/hcloud.rb

47 lines
1.6 KiB
Ruby
Raw Normal View History

class Hcloud < Formula
desc "Command-line interface for Hetzner Cloud"
homepage "https://github.com/hetznercloud/cli"
url "https://github.com/hetznercloud/cli/archive/v1.4.0.tar.gz"
sha256 "a09c07c2d081ab7493bc402246bd09d486f9fa5241a67e31e00564506c410507"
2018-04-10 01:46:31 +00:00
bottle do
cellar :any_skip_relocation
2018-04-18 07:18:45 +00:00
sha256 "5deffd6efe224636362ba5e995df57b3c4ec85065c15f8a55261608a7e590501" => :high_sierra
sha256 "72a32be135be4719a5ec50c1bb8762d1c3648c7f6a5a814b234b2d69c7341300" => :sierra
sha256 "eb41b7bd5cc58860c20b4d7e06d93e4d2d9ec7fac6bc070c2e401a488098a3a8" => :el_capitan
2018-04-10 01:46:31 +00:00
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/hetznercloud/cli").install buildpath.children
cd "src/github.com/hetznercloud/cli" do
ldflags = "-w -X github.com/hetznercloud/cli.Version=v#{version}"
system "go", "build", "-o", bin/"hcloud", "-ldflags", ldflags,
"./cmd/hcloud"
prefix.install_metafiles
end
output = Utils.popen_read("#{bin}/hcloud completion bash")
(bash_completion/"hcloud").write output
output = Utils.popen_read("#{bin}/hcloud completion zsh")
(zsh_completion/"_hcloud").write output
end
test do
config_path = testpath/".config/hcloud/cli.toml"
ENV["HCLOUD_CONFIG"] = config_path
assert_match "", shell_output("#{bin}/hcloud context active")
config_path.write <<~EOS
active_context = "test"
[[contexts]]
name = "test"
token = "foobar"
EOS
assert_match "test", shell_output("#{bin}/hcloud context list")
assert_match "test", shell_output("#{bin}/hcloud context active")
end
end