From e368e070c258cca1f9dfc2547cdc94f08a408a42 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Tue, 31 Aug 2021 20:16:54 -0400 Subject: [PATCH] cue 0.4.0 (new formula) Closes #84359. Signed-off-by: Rui Chen Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> --- Formula/cue.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Formula/cue.rb diff --git a/Formula/cue.rb b/Formula/cue.rb new file mode 100644 index 00000000000..1c97e7267e9 --- /dev/null +++ b/Formula/cue.rb @@ -0,0 +1,46 @@ +class Cue < Formula + desc "Validate and define text-based and dynamic configuration" + homepage "https://cuelang.org/" + url "https://github.com/cue-lang/cue/archive/v0.4.0.tar.gz" + sha256 "6989ada258115c24da78091e3692b94c54e33129f02e87ca4071240314cefebc" + license "Apache-2.0" + head "https://github.com/cue-lang/cue.git", branch: "master" + + depends_on "go" => :build + + def install + system "go", "build", *std_go_args(ldflags: "-s -w -X cuelang.org/go/cmd/cue/cmd.version=v#{version}"), "./cmd/cue" + + bash_output = Utils.safe_popen_read(bin/"cue", "completion", "bash") + (bash_completion/"cue").write bash_output + zsh_output = Utils.safe_popen_read(bin/"cue", "completion", "zsh") + (zsh_completion/"_cue").write zsh_output + fish_output = Utils.safe_popen_read(bin/"cue", "completion", "fish") + (fish_completion/"cue.fish").write fish_output + end + + test do + (testpath/"ranges.yml").write <<~EOS + min: 5 + max: 10 + --- + min: 10 + max: 5 + EOS + + (testpath/"check.cue").write <<~EOS + min?: *0 | number // 0 if undefined + max?: number & >min // must be strictly greater than min if defined. + EOS + + expected = <<~EOS + max: invalid value 5 (out of bound >10): + ./check.cue:2:16 + ./ranges.yml:5:7 + EOS + + assert_equal expected, shell_output(bin/"cue vet ranges.yml check.cue 2>&1", 1) + + assert_match version.to_s, shell_output(bin/"cue version") + end +end