lib/pdk/cli.rb in pdk-1.14.0 vs lib/pdk/cli.rb in pdk-1.14.1

- old
+ new

@@ -1,29 +1,25 @@ require 'cri' -require 'pdk/analytics' +require 'pdk' require 'pdk/cli/errors' -require 'pdk/cli/util' -require 'pdk/cli/util/command_redirector' -require 'pdk/cli/util/option_normalizer' -require 'pdk/cli/util/option_validator' -require 'pdk/config' -require 'pdk/i18n' -require 'pdk/logger' -require 'pdk/report' -require 'pdk/util/version' -require 'pdk/util/puppet_version' -require 'pdk/util/filesystem' +module TTY + autoload :Prompt, 'tty/prompt' + autoload :TestPrompt, 'tty/test_prompt' +end + class Cri::Command::CriExitException def initialize(is_error:) @is_error = is_error PDK.analytics.event('CLI', 'invalid command', label: PDK::CLI.anonymised_args.join(' ')) if error? end end module PDK::CLI + autoload :Util, 'pdk/cli/util' + # Attempt to anonymise the raw ARGV array if the command parsing failed. # # If an item does not start with '-' but is preceeded by an item that does # start with '-', assume that these items are an option/value pair and redact # the value. Any additional values that do not start with '-' that follow an @@ -48,12 +44,28 @@ in_args ? 'redacted' : arg end end end + def self.deprecated_runtime? + Gem::Version.new(RbConfig::CONFIG['ruby_version']) < Gem::Version.new('2.4.0') + end + def self.run(args) + if deprecated_runtime? + PDK.logger.info( + text: _( + 'Support for Ruby versions older than 2.4 will be dropped in the ' \ + 'future PDK 2.0.0 release. We recommend updating your Ruby ' \ + 'installation to ensure that you can continue using the latest ' \ + 'version of PDK.', + ), + wrap: true, + ) + end + @args = args - PDK::Config.analytics_config_interview! unless ENV['PDK_DISABLE_ANALYTICS'] || PDK::Config.analytics_config_exist? + PDK::Config.analytics_config_interview! unless PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK::Config.analytics_config_exist? @base_cmd.run(args) rescue PDK::CLI::ExitWithError => e PDK.logger.send(e.log_level, e.message) exit e.exit_code