forked from cloudfoundry/homebrew-tap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bosh-cli.rb
33 lines (29 loc) · 1.11 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
class BoshCli < Formula
desc "New BOSH CLI (beta)"
homepage "https://bosh.io/docs/cli-v2.html"
version "6.2.1"
url "https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-#{version}-darwin-amd64"
sha256 "1d2ced5edc7a9406616df7ad9c0d4e3ade10d66d33e753885ab8e245c037e280"
depends_on :arch => :x86_64
option "with-bosh2", "Rename binary to 'bosh2'. Useful if the old Ruby CLI is needed."
def install
binary_name = build.with?("bosh2") ? "bosh2" : "bosh"
bin.install "bosh-cli-#{version}-darwin-amd64" => binary_name
(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