-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathbosh-cli.rb
50 lines (46 loc) · 1.72 KB
/
bosh-cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class BoshCli < Formula
desc "BOSH CLI"
homepage "https://bosh.io/docs/cli-v2.html"
version "7.9.0"
if OS.mac?
if Hardware::CPU.arm?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-arm64"
sha256 "1716b7dd8a0a9d1a6db33ebb5368f9b454e8e4a7bc7ba094de7f48f077c62922"
else
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-amd64"
sha256 "3c5f6fdd41052877a864bcb9cc6921cdf836bedae65d4e88486c62d7d1405137"
end
elsif OS.linux?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-linux-amd64"
sha256 "de3001ce5f14f9d40cd72cc22d9626c5d806e46f0d061c69e725841e12830847"
end
option "with-bosh2", "Rename binary to 'bosh2'. Useful if the old Ruby CLI is needed."
def install
binary_name = build.with?("bosh2") ? "bosh2" : "bosh"
if OS.mac?
if Hardware::CPU.arm?
bin.install "bosh-cli-#{version}-darwin-arm64" => binary_name
else
bin.install "bosh-cli-#{version}-darwin-amd64" => binary_name
end
elsif OS.linux?
bin.install "bosh-cli-#{version}-linux-amd64" => binary_name
end
(bash_completion/"bosh-cli").write <<-completion
_#{binary_name}() {
# All arguments except the first one
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
# Only split on newlines
local IFS=$'\n'
# Call completion (note that the first element of COMP_WORDS is
# the executable itself)
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}
complete -o default -F _#{binary_name} #{binary_name}
completion
end
test do
system "#{bin}/#{binary_name} --help"
end
end