47 lines
1.7 KiB
Ruby
47 lines
1.7 KiB
Ruby
class Hcloud < Formula
|
|
desc "Command-line interface for Hetzner Cloud"
|
|
homepage "https://github.com/hetznercloud/cli"
|
|
url "https://github.com/hetznercloud/cli/archive/v1.11.0.tar.gz"
|
|
sha256 "af3b457297b5d60affac8fe102b154f0515b7032a93d5c88334f82371163fef0"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "6c2ef22d453654e28fac1c2898076e2cc43b2ace6cde1a4421b830a03261ed7c" => :mojave
|
|
sha256 "f732da0030a0ed8724869bdf13456f52fa9c6caee8c9e743e3cbd321a0fcbb86" => :high_sierra
|
|
sha256 "8972ae34c2984063589c40f478e0033c27bde8a4a588af945c8b32f7597a0354" => :sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = HOMEBREW_CACHE/"go_cache"
|
|
(buildpath/"src/github.com/hetznercloud/cli").install buildpath.children
|
|
|
|
cd "src/github.com/hetznercloud/cli" do
|
|
ldflags = "-w -X github.com/hetznercloud/cli/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")
|
|
assert_match "hcloud v#{version}", shell_output("#{bin}/hcloud version")
|
|
end
|
|
end
|