-
Notifications
You must be signed in to change notification settings - Fork 49
/
bosh-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.8.1"
if OS.mac?
if Hardware::CPU.arm?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-arm64"
sha256 "5a41a41062eecc5c94a03b1401935b9b55912206249bfc8802074f0fc07e4a64"
else
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-amd64"
sha256 "5c070d0a5cedb2089da696cc441d583b64920e314bb2fd57f386a096a18a4b69"
end
elsif OS.linux?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-linux-amd64"
sha256 "fcbbed4a296d7a0f247b30629810470b3f8617d97b5cbaa909c56783094e6f62"
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