From 856ef4e31bca64008c6bfeac3537be978f3d8b0b Mon Sep 17 00:00:00 2001 From: Nikita Mathur Date: Wed, 28 Jul 2021 12:47:48 +0530 Subject: [PATCH] Chef license accept fix to show license accepted message and quit when no other option/command passed Signed-off-by: Nikita Mathur --- lib/inspec/base_cli.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/inspec/base_cli.rb b/lib/inspec/base_cli.rb index 337c6930f..77b32a931 100644 --- a/lib/inspec/base_cli.rb +++ b/lib/inspec/base_cli.rb @@ -43,11 +43,15 @@ module Inspec begin if (allowed_commands & ARGV.map(&:downcase)).empty? && # Did they use a non-exempt command? !ARGV.empty? # Did they supply at least one command? - LicenseAcceptance::Acceptor.check_and_persist( + license_acceptor_output = LicenseAcceptance::Acceptor.check_and_persist( Inspec::Dist::EXEC_NAME, Inspec::VERSION, logger: Inspec::Log ) + if license_acceptor_output && ARGV.count == 1 && (ARGV.first.include? "--chef-license") + Inspec::UI.new.exit + end + license_acceptor_output end rescue LicenseAcceptance::LicenseNotAcceptedError Inspec::Log.error "#{Inspec::Dist::PRODUCT_NAME} cannot execute without accepting the license"