From 78fe082a2b85f097dae7b8333ba66a8fd31ca2d0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 24 Dec 2017 14:56:07 +0000 Subject: [PATCH] cask: exit successfully when given no arguments Fixes https://github.com/Homebrew/brew/issues/3601. --- Library/Homebrew/cask/lib/hbc/cli.rb | 1 + Library/Homebrew/test/cask/cli_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index a553ad6dac..5da2a137a2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -229,6 +229,7 @@ module Hbc purpose usage + return if @command.nil? return if @command == "help" && @args.empty? raise ArgumentError, "help does not take arguments." diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb index 4a61e00883..f88af41881 100644 --- a/Library/Homebrew/test/cask/cli_spec.rb +++ b/Library/Homebrew/test/cask/cli_spec.rb @@ -16,10 +16,16 @@ describe Hbc::CLI, :cask do it "ignores the `--language` option, which is handled in `OS::Mac`" do cli = described_class.new("--language=en") expect(cli).to receive(:detect_command_and_arguments).with(no_args) - expect(cli).to receive(:exit).with(1) cli.run end + context "when given no arguments" do + it "exits successfully" do + expect(subject).not_to receive(:exit).with(be_nonzero) + subject.run + end + end + context "when no option is specified" do it "--binaries is true by default" do command = Hbc::CLI::Install.new("some-cask")