-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathbosh-cli.rb
More file actions
50 lines (46 loc) · 1.72 KB
/
bosh-cli.rb
File metadata and controls
50 lines (46 loc) · 1.72 KB
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.10.3"
if OS.mac?
if Hardware::CPU.arm?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-arm64"
sha256 "63b7bb9d5532b32ca91cf3a0cc08203c8513b449165beaca1415097032137e2f"
else
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-amd64"
sha256 "b906777c06b99f4167df11767140d2c0acaf358771bead0c0709ed2cfc7ba56c"
end
elsif OS.linux?
url "https://storage.googleapis.com/bosh-cli-artifacts/bosh-cli-#{version}-linux-amd64"
sha256 "b3dddccb69e9f9de4f3f21c9c18aa748c647bb0e01aeb44c2edbb27afcd0ef57"
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