pdk 1.16.0 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/lib/pdk.rb +25 -18
  4. data/lib/pdk/answer_file.rb +2 -93
  5. data/lib/pdk/cli.rb +1 -5
  6. data/lib/pdk/cli/config.rb +3 -1
  7. data/lib/pdk/cli/config/get.rb +3 -1
  8. data/lib/pdk/cli/convert.rb +1 -1
  9. data/lib/pdk/cli/exec/command.rb +13 -0
  10. data/lib/pdk/cli/exec_group.rb +78 -43
  11. data/lib/pdk/cli/get.rb +20 -0
  12. data/lib/pdk/cli/get/config.rb +24 -0
  13. data/lib/pdk/cli/util.rb +6 -3
  14. data/lib/pdk/cli/validate.rb +26 -44
  15. data/lib/pdk/config.rb +178 -4
  16. data/lib/pdk/config/ini_file.rb +183 -0
  17. data/lib/pdk/config/ini_file_setting.rb +39 -0
  18. data/lib/pdk/config/namespace.rb +25 -5
  19. data/lib/pdk/config/setting.rb +3 -2
  20. data/lib/pdk/context.rb +96 -0
  21. data/lib/pdk/context/control_repo.rb +60 -0
  22. data/lib/pdk/context/module.rb +28 -0
  23. data/lib/pdk/context/none.rb +22 -0
  24. data/lib/pdk/control_repo.rb +40 -0
  25. data/lib/pdk/generate/module.rb +8 -12
  26. data/lib/pdk/module/release.rb +2 -8
  27. data/lib/pdk/util.rb +35 -5
  28. data/lib/pdk/util/bundler.rb +1 -0
  29. data/lib/pdk/util/changelog_generator.rb +6 -1
  30. data/lib/pdk/util/template_uri.rb +4 -3
  31. data/lib/pdk/validate.rb +72 -25
  32. data/lib/pdk/validate/external_command_validator.rb +208 -0
  33. data/lib/pdk/validate/internal_ruby_validator.rb +100 -0
  34. data/lib/pdk/validate/invokable_validator.rb +216 -0
  35. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -0
  36. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -0
  37. data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -0
  38. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -0
  39. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -0
  40. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -0
  41. data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -0
  42. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -0
  43. data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -0
  44. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -0
  45. data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -0
  46. data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -0
  47. data/lib/pdk/validate/validator.rb +111 -0
  48. data/lib/pdk/validate/validator_group.rb +103 -0
  49. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -0
  50. data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -0
  51. data/lib/pdk/version.rb +1 -1
  52. data/locales/pdk.pot +161 -125
  53. metadata +29 -17
  54. data/lib/pdk/validate/base_validator.rb +0 -215
  55. data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -82
  56. data/lib/pdk/validate/metadata/metadata_syntax.rb +0 -111
  57. data/lib/pdk/validate/metadata_validator.rb +0 -26
  58. data/lib/pdk/validate/puppet/puppet_epp.rb +0 -135
  59. data/lib/pdk/validate/puppet/puppet_lint.rb +0 -64
  60. data/lib/pdk/validate/puppet/puppet_syntax.rb +0 -135
  61. data/lib/pdk/validate/puppet_validator.rb +0 -26
  62. data/lib/pdk/validate/ruby/rubocop.rb +0 -72
  63. data/lib/pdk/validate/ruby_validator.rb +0 -26
  64. data/lib/pdk/validate/tasks/metadata_lint.rb +0 -130
  65. data/lib/pdk/validate/tasks/name.rb +0 -90
  66. data/lib/pdk/validate/tasks_validator.rb +0 -29
  67. data/lib/pdk/validate/yaml/syntax.rb +0 -125
  68. data/lib/pdk/validate/yaml_validator.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fff9ce82e1ef158819f1089c8350fde37df2c9d8e105b09e4ecea52f542469bb
4
- data.tar.gz: cff148b17b8175f7fe5401d5de87bebd36de18b939dcec7c456793d1da674ef7
3
+ metadata.gz: 474d162028588f81742d07449993c5d483a850f8752fd316753bf3bbdddc4e1f
4
+ data.tar.gz: 856f5d44b107853f0cebfce208d157d33200b74d3478eb8aaa1d3d6756744126
5
5
  SHA512:
6
- metadata.gz: 0b8b0dc86dec798fcb51c8c1ab44ae0f591f84e0b6ee86ad6ede292e3fbd496495584ce83bcafdc6791bf93bdb134678033dbb695e9fb84519844bb7a776e69a
7
- data.tar.gz: 365ba46da5e62d7519b9df797140cf75c904e2d64765b1ef72a6161e53a0e98bba5c2a8948404c6e2aff67b45678e842bd1621b86b8f334e4a7add46881948d3
6
+ metadata.gz: eed98a917574715ad9b01993a2b19137d8e3da107a17f5d3e19694619f19d117648aa89abffb4c8df09cd4e0fded23023e08fb395f2f5a80513e685a20b60185
7
+ data.tar.gz: c497f0dc4af2134bfaab6870b8b1bd4525c27629e4cc86295efd915aaef194f764717a83cd705c569b668a8a66f26087605b5dcfbbf8f6ae3e2e0f74b2c5f4b5
@@ -4,6 +4,30 @@ All changes to this repo will be documented in this file.
4
4
  See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) for a high-level summary.
5
5
 
6
6
 
7
+ ## [v1.17.0](https://github.com/puppetlabs/pdk/tree/v1.17.0) (2020-02-27)
8
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.16.0...v1.17.0)
9
+
10
+ **Implemented enhancements:**
11
+
12
+ - \(PDK-1618\)\(PDK-1613\)\(PDK-1616\) Add Control Repo support to Validators [\#858](https://github.com/puppetlabs/pdk/pull/858) ([glennsarti](https://github.com/glennsarti))
13
+ - \(PDK-1614\) Add project.environment settings [\#857](https://github.com/puppetlabs/pdk/pull/857) ([glennsarti](https://github.com/glennsarti))
14
+ - \(PDK-1615\) Add Ini File configuration support [\#856](https://github.com/puppetlabs/pdk/pull/856) ([glennsarti](https://github.com/glennsarti))
15
+ - \(PDK-1612\) Add PDK::Context and context detection [\#853](https://github.com/puppetlabs/pdk/pull/853) ([glennsarti](https://github.com/glennsarti))
16
+ - \(PDK-1607\)\(PDK-1608\) Implement system-level settings for PDK configuration [\#841](https://github.com/puppetlabs/pdk/pull/841) ([glennsarti](https://github.com/glennsarti))
17
+
18
+ **Fixed bugs:**
19
+
20
+ - Unable to automatically generate the changelog [\#855](https://github.com/puppetlabs/pdk/issues/855)
21
+ - 'pdk new module' bundler error with PDK-1.16 on macOS 10.14 [\#845](https://github.com/puppetlabs/pdk/issues/845)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - \(\#855\) Use correct namespace for external Bundler call [\#860](https://github.com/puppetlabs/pdk/pull/860) ([rodjek](https://github.com/rodjek))
26
+ - \(maint\) Use Ruby 2.5 on Travis for PDK as a library tests [\#849](https://github.com/puppetlabs/pdk/pull/849) ([glennsarti](https://github.com/glennsarti))
27
+ - \(maint\) Update for Ruby 2.3 and JSON Schema tests [\#847](https://github.com/puppetlabs/pdk/pull/847) ([glennsarti](https://github.com/glennsarti))
28
+ - \(maint\) Add basic tests for running PDK unprivileged [\#846](https://github.com/puppetlabs/pdk/pull/846) ([rodjek](https://github.com/rodjek))
29
+ - \(PDK-1592\) Refactor PDK validators to be more singular purpose [\#831](https://github.com/puppetlabs/pdk/pull/831) ([glennsarti](https://github.com/glennsarti))
30
+
7
31
  ## [v1.16.0](https://github.com/puppetlabs/pdk/tree/v1.16.0) (2020-02-05)
8
32
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.15.0...v1.16.0)
9
33
 
data/lib/pdk.rb CHANGED
@@ -5,6 +5,7 @@ module PDK
5
5
  autoload :AnswerFile, 'pdk/answer_file'
6
6
  autoload :Bolt, 'pdk/bolt'
7
7
  autoload :Config, 'pdk/config'
8
+ autoload :Context, 'pdk/context'
8
9
  autoload :ControlRepo, 'pdk/control_repo'
9
10
  autoload :Generate, 'pdk/generate'
10
11
  autoload :Logger, 'pdk/logger'
@@ -30,35 +31,41 @@ module PDK
30
31
  autoload :Unit, 'pdk/tests/unit'
31
32
  end
32
33
 
33
- # Singleton accessor to the current answer file being used by the PDK.
34
- #
35
- # @return [PDK::AnswerFile] The AnswerFile instance currently being used by
36
- # the PDK.
37
- def self.answers
38
- @answer_file ||= PDK::AnswerFile.new
34
+ def self.logger
35
+ @logger ||= PDK::Logger.new
39
36
  end
40
37
 
41
- # Specify the path to a custom answer file that the PDK should use.
42
- #
43
- # @param path [String] A path on disk to the file where the PDK should store
44
- # answers to interactive questions.
45
- def self.answer_file=(path)
46
- @answer_file = PDK::AnswerFile.new(path)
38
+ def self.config
39
+ return @config unless @config.nil?
40
+ options = {}
41
+ options['user.module_defaults.path'] = PDK::Util::Env['PDK_ANSWER_FILE'] unless PDK::Util::Env['PDK_ANSWER_FILE'].nil?
42
+ @config = PDK::Config.new(options)
47
43
  end
48
44
 
49
- def self.logger
50
- @logger ||= PDK::Logger.new
45
+ def self.context
46
+ @context ||= PDK::Context.create(Dir.pwd)
51
47
  end
52
48
 
53
- def self.config
54
- @config ||= PDK::Config.new
49
+ def self.available_feature_flags
50
+ @available_feature_flags ||= %w[
51
+ controlrepo
52
+ ].freeze
53
+ end
54
+
55
+ def self.requested_feature_flags
56
+ @requested_feature_flags ||= (PDK::Util::Env['PDK_FEATURE_FLAGS'] || '').split(',').map { |flag| flag.strip }
57
+ end
58
+
59
+ def self.feature_flag?(flagname)
60
+ return false unless available_feature_flags.include?(flagname)
61
+ requested_feature_flags.include?(flagname)
55
62
  end
56
63
 
57
64
  def self.analytics
58
65
  @analytics ||= PDK::Analytics.build_client(
59
66
  logger: PDK.logger,
60
- disabled: PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK.config.user['analytics']['disabled'],
61
- user_id: PDK.config.user['analytics']['user-id'],
67
+ disabled: PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK.config.get_within_scopes('analytics.disabled', %w[user system]),
68
+ user_id: PDK.config.get_within_scopes('analytics.user-id', %w[user system]),
62
69
  app_id: "UA-139917834-#{PDK::Util.development_mode? ? '2' : '1'}",
63
70
  client: :google_analytics,
64
71
  app_name: 'pdk',
@@ -1,103 +1,12 @@
1
1
  require 'pdk'
2
- autoload :JSON, 'json'
3
2
 
4
3
  module PDK
5
4
  class AnswerFile
6
- attr_reader :answers
7
- attr_reader :answer_file_path
8
-
9
- # Initialises the AnswerFile object, which stores the responses to certain
10
- # interactive questions.
11
- #
12
- # @param answer_file_path [String, nil] The path on disk to the file where
13
- # the answers will be stored and read from. If not specified (or `nil`),
14
- # the default path will be used (see #default_answer_file_path).
15
- #
16
- # @raise (see #read_from_disk)
17
- def initialize(answer_file_path = nil)
18
- @answer_file_path = answer_file_path || default_answer_file_path
19
- @answers = read_from_disk
20
- end
21
-
22
- # Retrieve the stored answer to a question.
23
- #
24
- # @param question [String] The question name/identifying string.
25
- #
26
- # @return [Object] The answer to the question, or `nil` if no answer found.
27
- def [](question)
28
- answers[question]
29
- end
30
-
31
- # Update the stored answers in memory and then save them to disk.
32
- #
33
- # @param new_answers [Hash{String => Object}] The new questions and answers
34
- # to be merged into the existing answers.
35
- #
36
- # @raise [PDK::CLI::FatalError] if the new answers are not provided as
37
- # a Hash.
38
- # @raise (see #save_to_disk)
39
- def update!(new_answers = {})
40
- unless new_answers.is_a?(Hash)
41
- raise PDK::CLI::FatalError, _('Answer file can be updated only with a Hash')
42
- end
43
-
44
- answers.merge!(new_answers)
45
-
46
- save_to_disk
47
- end
48
-
49
- private
50
-
51
5
  # Determine the default path to the answer file.
52
6
  #
53
7
  # @return [String] The path on disk to the default answer file.
54
- def default_answer_file_path
55
- File.join(PDK::Util.cachedir, 'answers.json')
56
- end
57
-
58
- # Read existing answers into memory from the answer file on disk.
59
- #
60
- # @raise [PDK::CLI::FatalError] If the answer file exists but can not be
61
- # read.
62
- #
63
- # @return [Hash{String => Object}] The existing questions and answers.
64
- def read_from_disk
65
- return {} if !PDK::Util::Filesystem.file?(answer_file_path) || PDK::Util::Filesystem.zero?(answer_file_path)
66
-
67
- unless PDK::Util::Filesystem.readable?(answer_file_path)
68
- raise PDK::CLI::FatalError, _("Unable to open '%{file}' for reading") % {
69
- file: answer_file_path,
70
- }
71
- end
72
-
73
- answers = JSON.parse(PDK::Util::Filesystem.read_file(answer_file_path))
74
- if answers.is_a?(Hash)
75
- answers
76
- else
77
- PDK.logger.warn _("Answer file '%{path}' did not contain a valid set of answers, recreating it") % {
78
- path: answer_file_path,
79
- }
80
- {}
81
- end
82
- rescue JSON::JSONError
83
- PDK.logger.warn _("Answer file '%{path}' did not contain valid JSON, recreating it") % {
84
- path: answer_file_path,
85
- }
86
- {}
87
- end
88
-
89
- # Save the in memory answer set to the answer file on disk.
90
- #
91
- # @raise [PDK::CLI::FatalError] if the answer file can not be written to.
92
- def save_to_disk
93
- PDK::Util::Filesystem.mkdir_p(File.dirname(answer_file_path))
94
-
95
- PDK::Util::Filesystem.write_file(answer_file_path, JSON.pretty_generate(answers))
96
- rescue SystemCallError, IOError => e
97
- raise PDK::CLI::FatalError, _("Unable to write '%{file}': %{msg}") % {
98
- file: answer_file_path,
99
- msg: e.message,
100
- }
8
+ def self.default_answer_file_path
9
+ PDK::Util::Filesystem.expand_path(File.join(PDK::Util.cachedir, 'answers.json'))
101
10
  end
102
11
  end
103
12
  end
@@ -150,17 +150,13 @@ module PDK::CLI
150
150
  flag :d, :debug, _('Enable debug output.') do |_, _|
151
151
  PDK.logger.enable_debug_output
152
152
  end
153
-
154
- option nil, 'answer-file', _('Path to an answer file.'), argument: :required, hidden: true do |value|
155
- require 'pdk/answer_file'
156
- PDK.answer_file = value
157
- end
158
153
  end
159
154
 
160
155
  require 'pdk/cli/bundle'
161
156
  require 'pdk/cli/build'
162
157
  require 'pdk/cli/config'
163
158
  require 'pdk/cli/convert'
159
+ require 'pdk/cli/get'
164
160
  require 'pdk/cli/new'
165
161
  require 'pdk/cli/test'
166
162
  require 'pdk/cli/update'
@@ -2,10 +2,12 @@ module PDK::CLI
2
2
  @config_cmd = @base_cmd.define_command do
3
3
  name 'config'
4
4
  usage _('config [subcommand] [options]')
5
- summary _('Configure the Puppet Development Kit.')
5
+ summary _('(Deprecated) Configure the Puppet Development Kit.')
6
6
  default_subcommand 'help'
7
7
 
8
8
  run do |_opts, args, _cmd|
9
+ PDK.logger.warn _('The \'pdk config\' command is deprecated, please use \'pdk get config\' and \'pdk set config\' instead.')
10
+
9
11
  if args == ['help']
10
12
  PDK::CLI.run(%w[config --help])
11
13
  exit 0
@@ -2,9 +2,11 @@ module PDK::CLI
2
2
  @config_get_cmd = @config_cmd.define_command do
3
3
  name 'get'
4
4
  usage _('config get [name]')
5
- summary _('Retrieve the configuration for <name>. If not specified, retrieve all configuration settings')
5
+ summary _('(Deprecated) Retrieve the configuration for <name>. If not specified, retrieve all configuration settings')
6
6
 
7
7
  run do |_opts, args, _cmd|
8
+ PDK.logger.warn _('The \'pdk config get\' command is deprecated, please use \'pdk get config\' instead.')
9
+
8
10
  item_name = args[0]
9
11
  resolved_config = PDK.config.resolve(item_name)
10
12
  # If the user wanted to know a setting but it doesn't exist, raise an error
@@ -31,7 +31,7 @@ module PDK::CLI
31
31
  raise PDK::CLI::ExitWithError, _('You can not specify --template-url and --default-template.') if opts[:'template-url']
32
32
 
33
33
  opts[:'template-url'] = PDK::Util::TemplateURI.default_template_addressable_uri.to_s
34
- PDK.answers.update!('template-url' => nil)
34
+ PDK.config.user['module_defaults']['template-url'] = nil
35
35
  end
36
36
 
37
37
  PDK::CLI::Util.validate_template_opts(opts)
@@ -10,6 +10,14 @@ module PDK
10
10
  attr_accessor :environment
11
11
  attr_writer :exec_group
12
12
 
13
+ # The spinner for this command.
14
+ # This should only be used for testing
15
+ #
16
+ # @return [TTY::Spinner, nil]
17
+ #
18
+ # @api private
19
+ attr_reader :spinner
20
+
13
21
  TEMPFILE_MODE = File::RDWR | File::BINARY | File::CREAT | File::TRUNC
14
22
 
15
23
  def initialize(*argv)
@@ -71,6 +79,11 @@ module PDK
71
79
  @environment.merge!(additional_env)
72
80
  end
73
81
 
82
+ # @return [Hash[Symbol => Object]] The result from executing the command
83
+ # :stdout => String : The result of STDOUT
84
+ # :stderr => String : The result of STDERR
85
+ # :exit_code => Integer : The exit code from the command
86
+ # :duration => Float : Number seconds it took to execute
74
87
  def execute!
75
88
  # Start spinning if configured.
76
89
  @spinner.auto_spin if @spinner
@@ -3,66 +3,101 @@ require 'pdk'
3
3
  module PDK
4
4
  module CLI
5
5
  class ExecGroup
6
- def initialize(message, opts = {})
7
- require 'pdk/cli/util'
8
- @options = opts.merge(PDK::CLI::Util.spinner_opts_for_platform)
9
-
10
- if PDK::CLI::Util.interactive?
11
- require 'pdk/cli/util/spinner'
12
-
13
- @spinner = if parallel?
14
- TTY::Spinner::Multi.new("[:spinner] #{message}", @options)
15
- else
16
- TTY::Spinner.new("[:spinner] #{message}", @options)
17
- end
18
- @spinner.auto_spin
6
+ # Execution Group (ExecGroup) factory.
7
+ #
8
+ # @param message [String] A name or message for this group. Provided for backwards compatibility during refactor
9
+ #
10
+ # @param create_options [Hash] A hash options used during creation of the ExecGroup. This are not passed to the new object
11
+ # @option create_options :parallel [Boolean] Whether the group should be executed in Parallel (True) or Serial (False)
12
+ #
13
+ # @param group_opts [Hash] A hash of options used to configure the execution group. Provided for backwards compatibility during refactor
14
+ #
15
+ # @return [ExecGroup]
16
+ def self.create(message, create_options = {}, group_opts = {})
17
+ if create_options[:parallel]
18
+ ParallelExecGroup.new(message, group_opts)
19
+ else
20
+ SerialExecGroup.new(message, group_opts)
19
21
  end
20
-
21
- @threads_or_procs = []
22
- @exit_codes = []
23
22
  end
24
23
 
25
- def parallel?
26
- @options[:parallel].nil? ? true : @options[:parallel]
24
+ # Base class for an Exection Group
25
+ #
26
+ # @param message [String] A name or message for this group. Provided for backwards compatibility during refactor
27
+ #
28
+ # @param opts [Hash] A hash of options used to configure the execution group. Provided for backwards compatibility during refactor
29
+ #
30
+ # @api private
31
+ def initialize(_message, opts = {})
32
+ @options = opts
27
33
  end
28
34
 
29
- def register(&block)
35
+ # Register something to execute as a group
36
+ #
37
+ # @param block [Block] A block of ruby to execute
38
+ #
39
+ # @api private
40
+ def register(&_block)
30
41
  raise PDK::CLI::FatalError, _('No block registered') unless block_given?
42
+ end
43
+
44
+ # The return code of running all registered blocks
45
+ #
46
+ # @return [int] The highest exit code from the blocks
47
+ #
48
+ # @abstract
49
+ def exit_code; end
50
+ end
31
51
 
32
- @threads_or_procs << if parallel?
33
- Thread.new do
34
- GettextSetup.initialize(File.absolute_path('../../../locales', File.dirname(__FILE__)))
35
- GettextSetup.negotiate_locale!(GettextSetup.candidate_locales)
36
- @exit_codes << yield
37
- end
38
- else
39
- block
40
- end
52
+ # Executes registered blocks in serial
53
+ #
54
+ # @see PDK::CLI::ExecGroup
55
+ class SerialExecGroup < ExecGroup
56
+ def initialize(message, opts = {})
57
+ super(message, opts)
58
+ @procs = []
41
59
  end
42
60
 
43
- def add_spinner(message, opts = {})
44
- require 'pdk/cli/util'
61
+ def register(&block)
62
+ super(&block)
45
63
 
46
- return unless PDK::CLI::Util.interactive?
47
- @spinner.register("[:spinner] #{message}", @options.merge(opts).merge(PDK::CLI::Util.spinner_opts_for_platform))
64
+ @procs << block
48
65
  end
49
66
 
50
67
  def exit_code
51
- if parallel?
52
- @threads_or_procs.each(&:join)
53
- else
54
- @exit_codes = @threads_or_procs.map(&:call)
55
- end
68
+ exit_codes = @procs.map(&:call)
69
+ exit_codes.nil? ? 0 : exit_codes.max
70
+ end
71
+ end
56
72
 
57
- exit_code = @exit_codes.max
73
+ # Executes registered blocks in parallel using Ruby threads
74
+ #
75
+ # @see PDK::CLI::ExecGroup
76
+ class ParallelExecGroup < ExecGroup
77
+ def initialize(message, opts = {})
78
+ super(message, opts)
79
+ @threads = []
80
+ @exit_codes = []
81
+ end
82
+
83
+ def register(&block)
84
+ super(&block)
58
85
 
59
- if exit_code.zero? && @spinner
60
- @spinner.success
61
- elsif @spinner
62
- @spinner.error
86
+ # TODO: This executes the thread immediately, whereas the SerialExecGroup executes only when exit_code
87
+ # is called. Need to change this so it uses a kind of ThreadPool to limit to number on concurrent jobs
88
+ # and only starts on the call to exit_code
89
+ # e.g. max_threads = No. of CPUs
90
+ @threads << Thread.new do
91
+ GettextSetup.initialize(File.absolute_path('../../../locales', File.dirname(__FILE__)))
92
+ GettextSetup.negotiate_locale!(GettextSetup.candidate_locales)
93
+ @exit_codes << yield
63
94
  end
95
+ end
64
96
 
65
- exit_code
97
+ def exit_code
98
+ @threads.each(&:join)
99
+ return 0 if @exit_codes.empty?
100
+ @exit_codes.max
66
101
  end
67
102
  end
68
103
  end
@@ -0,0 +1,20 @@
1
+ module PDK::CLI
2
+ @get_cmd = @base_cmd.define_command do
3
+ name 'get'
4
+ usage _('get [subcommand] [options]')
5
+ summary _('Retrieve information about the PDK or current project.')
6
+ default_subcommand 'help'
7
+
8
+ run do |_opts, args, _cmd|
9
+ if args == ['help']
10
+ PDK::CLI.run(%w[get --help])
11
+ exit 0
12
+ end
13
+
14
+ PDK::CLI.run(%w[get help]) if args.empty?
15
+ end
16
+ end
17
+ @get_cmd.add_command Cri::Command.new_basic_help
18
+ end
19
+
20
+ require 'pdk/cli/get/config'