2018-04-06 10:52:49 +00:00
|
|
|
class Hcloud < Formula
|
|
|
|
desc "Command-line interface for Hetzner Cloud"
|
|
|
|
homepage "https://github.com/hetznercloud/cli"
|
|
|
|
url "https://github.com/hetznercloud/cli/archive/v1.3.2.tar.gz"
|
|
|
|
sha256 "1cac1e7a5618abce0e6e2d5da40afc153fd88508557afdf90d0f5be54abec9a9"
|
|
|
|
|
2018-04-10 01:46:31 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
|
|
|
sha256 "6a2721f2f0ad3a6159420016afd29eed297888921b44cbeec0476a10fa870320" => :high_sierra
|
|
|
|
sha256 "d3fbff2fc949ba19e4181d58b34a63c0aa0263540003acd33a37b652b660a7ef" => :sierra
|
|
|
|
sha256 "c6682a43394dd4f4bb262305469969db8b441170b0024748ff7c447b7e4a95dd" => :el_capitan
|
|
|
|
end
|
|
|
|
|
2018-04-06 10:52:49 +00:00
|
|
|
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
|