facter 4.0.39 → 4.0.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/bin/facter +3 -4
  3. data/lib/facter.rb +107 -28
  4. data/lib/facter/config.rb +354 -0
  5. data/lib/facter/custom_facts/core/aggregate.rb +51 -17
  6. data/lib/facter/custom_facts/core/execution.rb +27 -35
  7. data/lib/facter/custom_facts/core/execution/base.rb +13 -7
  8. data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
  9. data/lib/facter/custom_facts/util/fact.rb +1 -1
  10. data/lib/facter/custom_facts/util/resolution.rb +40 -11
  11. data/lib/facter/facts/aix/disks.rb +1 -1
  12. data/lib/facter/facts/linux/ec2_metadata.rb +5 -29
  13. data/lib/facter/facts/linux/ec2_userdata.rb +5 -27
  14. data/lib/facter/facts/linux/is_virtual.rb +7 -46
  15. data/lib/facter/facts/linux/virtual.rb +3 -58
  16. data/lib/facter/facts/rhel/os/release.rb +1 -1
  17. data/lib/facter/facts/solaris/disks.rb +1 -1
  18. data/lib/facter/facts/solaris/zones.rb +1 -1
  19. data/lib/facter/facts_utils/virtual_detector.rb +78 -0
  20. data/lib/facter/framework/benchmarking/timer.rb +4 -2
  21. data/lib/facter/framework/cli/cli.rb +83 -36
  22. data/lib/facter/framework/cli/cli_launcher.rb +34 -38
  23. data/lib/facter/framework/config/fact_groups.rb +41 -7
  24. data/lib/facter/framework/core/cache_manager.rb +43 -23
  25. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +14 -11
  26. data/lib/facter/framework/core/options/config_file_options.rb +5 -3
  27. data/lib/facter/framework/core/options/option_store.rb +60 -27
  28. data/lib/facter/framework/detector/os_hierarchy.rb +5 -9
  29. data/lib/facter/framework/logging/logger.rb +1 -5
  30. data/lib/facter/resolvers/aix/architecture_resolver.rb +15 -1
  31. data/lib/facter/resolvers/aix/os_level.rb +1 -1
  32. data/lib/facter/resolvers/augeas_resolver.rb +7 -1
  33. data/lib/facter/resolvers/bsd/processors.rb +11 -7
  34. data/lib/facter/resolvers/disk_resolver.rb +11 -3
  35. data/lib/facter/resolvers/dmi_decode.rb +1 -0
  36. data/lib/facter/resolvers/dmi_resolver.rb +2 -2
  37. data/lib/facter/resolvers/freebsd/geom_resolver.rb +12 -20
  38. data/lib/facter/resolvers/freebsd/processors.rb +11 -7
  39. data/lib/facter/resolvers/memory_resolver.rb +12 -14
  40. data/lib/facter/resolvers/mountpoints_resolver.rb +50 -22
  41. data/lib/facter/resolvers/networking_linux_resolver.rb +10 -5
  42. data/lib/facter/resolvers/partitions.rb +60 -57
  43. data/lib/facter/resolvers/processors_resolver.rb +5 -1
  44. data/lib/facter/resolvers/solaris/dmi.rb +2 -0
  45. data/lib/facter/resolvers/solaris/mountpoints.rb +60 -0
  46. data/lib/facter/resolvers/solaris/networking.rb +1 -2
  47. data/lib/facter/resolvers/solaris/os_release.rb +4 -3
  48. data/lib/facter/resolvers/ssh_resolver.rb +4 -4
  49. data/lib/facter/version.rb +1 -1
  50. metadata +5 -4
  51. data/lib/facter/fact_groups.conf +0 -308
  52. data/lib/facter/os_hierarchy.json +0 -36
@@ -24,7 +24,7 @@ module Facts
24
24
 
25
25
  def add_legacy_facts(disks, facts)
26
26
  disks.each do |disk_name, disk_info|
27
- facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_size", disk_info[:size_bytes].to_s, :legacy))
27
+ facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_size", disk_info[:size_bytes], :legacy))
28
28
  end
29
29
  end
30
30
  end
@@ -5,6 +5,10 @@ module Facts
5
5
  class Ec2Metadata
6
6
  FACT_NAME = 'ec2_metadata'
7
7
 
8
+ def initialize
9
+ @virtual = Facter::VirtualDetector.new
10
+ end
11
+
8
12
  def call_the_resolver
9
13
  return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors?
10
14
 
@@ -16,35 +20,7 @@ module Facts
16
20
  private
17
21
 
18
22
  def aws_hypervisors?
19
- virtual =~ /kvm|xen|aws/
20
- end
21
-
22
- def virtual
23
- check_virt_what || check_xen || check_product_name || check_bios_vendor || check_lspci
24
- end
25
-
26
- def check_virt_what
27
- Facter::Resolvers::VirtWhat.resolve(:vm)
28
- end
29
-
30
- def check_xen
31
- Facter::Resolvers::Xen.resolve(:vm)
32
- end
33
-
34
- def check_product_name
35
- product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
36
- return unless product_name
37
-
38
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
39
- end
40
-
41
- def check_bios_vendor
42
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
43
- return 'kvm' if bios_vendor&.include?('Amazon EC2')
44
- end
45
-
46
- def check_lspci
47
- Facter::Resolvers::Lspci.resolve(:vm)
23
+ @virtual.platform =~ /kvm|xen|aws/
48
24
  end
49
25
  end
50
26
  end
@@ -5,6 +5,10 @@ module Facts
5
5
  class Ec2Userdata
6
6
  FACT_NAME = 'ec2_userdata'
7
7
 
8
+ def initialize
9
+ @virtual = Facter::VirtualDetector.new
10
+ end
11
+
8
12
  def call_the_resolver
9
13
  return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors?
10
14
 
@@ -16,33 +20,7 @@ module Facts
16
20
  private
17
21
 
18
22
  def aws_hypervisors?
19
- virtual = check_virt_what || check_xen || check_product_name || check_bios_vendor || check_lspci
20
-
21
- virtual == 'kvm' || virtual =~ /xen/
22
- end
23
-
24
- def check_virt_what
25
- Facter::Resolvers::VirtWhat.resolve(:vm)
26
- end
27
-
28
- def check_xen
29
- Facter::Resolvers::Xen.resolve(:vm)
30
- end
31
-
32
- def check_product_name
33
- product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
34
- return unless product_name
35
-
36
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
37
- end
38
-
39
- def check_bios_vendor
40
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
41
- return 'kvm' if bios_vendor&.include?('Amazon EC2')
42
- end
43
-
44
- def check_lspci
45
- Facter::Resolvers::Lspci.resolve(:vm)
23
+ @virtual.platform =~ /kvm|xen|aws/
46
24
  end
47
25
  end
48
26
  end
@@ -5,59 +5,20 @@ module Facts
5
5
  class IsVirtual
6
6
  FACT_NAME = 'is_virtual'
7
7
 
8
- def call_the_resolver # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
9
- fact_value = check_docker_lxc || check_gce || retrieve_from_virt_what || check_vmware
10
- fact_value ||= check_open_vz || check_vserver || check_xen || check_other_facts || check_lspci || 'physical'
11
-
12
- Facter::ResolvedFact.new(FACT_NAME, check_if_virtual(fact_value))
13
- end
14
-
15
- def check_gce
16
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
17
- 'gce' if bios_vendor&.include?('Google')
18
- end
19
-
20
- def check_docker_lxc
21
- Facter::Resolvers::Containers.resolve(:vm)
8
+ def initialize
9
+ @virtual = Facter::VirtualDetector.new
22
10
  end
23
11
 
24
- def check_vmware
25
- Facter::Resolvers::Vmware.resolve(:vm)
26
- end
12
+ def call_the_resolver
13
+ fact_value = @virtual.platform
27
14
 
28
- def retrieve_from_virt_what
29
- Facter::Resolvers::VirtWhat.resolve(:vm)
30
- end
31
-
32
- def check_open_vz
33
- Facter::Resolvers::OpenVz.resolve(:vm)
34
- end
35
-
36
- def check_vserver
37
- Facter::Resolvers::VirtWhat.resolve(:vserver)
38
- end
39
-
40
- def check_xen
41
- Facter::Resolvers::Xen.resolve(:vm)
42
- end
43
-
44
- def check_other_facts
45
- product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
46
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
47
- return 'kvm' if bios_vendor&.include?('Amazon EC2')
48
- return unless product_name
49
-
50
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
51
-
52
- nil
15
+ Facter::ResolvedFact.new(FACT_NAME, check_if_virtual(fact_value))
53
16
  end
54
17
 
55
- def check_lspci
56
- Facter::Resolvers::Lspci.resolve(:vm)
57
- end
18
+ private
58
19
 
59
20
  def check_if_virtual(found_vm)
60
- Facter::FactsUtils::PHYSICAL_HYPERVISORS.count(found_vm).zero?
21
+ Facter::FactsUtils::PHYSICAL_HYPERVISORS.count(found_vm).zero?.to_s
61
22
  end
62
23
  end
63
24
  end
@@ -7,71 +7,16 @@ module Facts
7
7
 
8
8
  def initialize
9
9
  @log = Facter::Log.new(self)
10
+ @virtual = Facter::VirtualDetector.new
10
11
  end
11
12
 
12
- def call_the_resolver # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
13
+ def call_the_resolver
13
14
  @log.debug('Linux Virtual Resolver')
14
-
15
- fact_value = check_docker_lxc || check_gce || retrieve_from_virt_what || check_vmware
16
- fact_value ||= check_open_vz || check_vserver || check_xen || check_other_facts || check_lspci || 'physical'
17
-
15
+ fact_value = @virtual.platform
18
16
  @log.debug("Fact value is: #{fact_value}")
19
17
 
20
18
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
21
19
  end
22
-
23
- def check_gce
24
- @log.debug('Checking GCE')
25
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
26
- 'gce' if bios_vendor&.include?('Google')
27
- end
28
-
29
- def check_docker_lxc
30
- @log.debug('Checking Docker and LXC')
31
- Facter::Resolvers::Containers.resolve(:vm)
32
- end
33
-
34
- def check_vmware
35
- @log.debug('Checking VMware')
36
- Facter::Resolvers::Vmware.resolve(:vm)
37
- end
38
-
39
- def retrieve_from_virt_what
40
- @log.debug('Checking virtual_what')
41
- Facter::Resolvers::VirtWhat.resolve(:vm)
42
- end
43
-
44
- def check_open_vz
45
- @log.debug('Checking OpenVZ')
46
- Facter::Resolvers::OpenVz.resolve(:vm)
47
- end
48
-
49
- def check_vserver
50
- @log.debug('Checking VServer')
51
- Facter::Resolvers::VirtWhat.resolve(:vserver)
52
- end
53
-
54
- def check_xen
55
- @log.debug('Checking XEN')
56
- Facter::Resolvers::Xen.resolve(:vm)
57
- end
58
-
59
- def check_other_facts
60
- @log.debug('Checking others')
61
- product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
62
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
63
- return 'kvm' if bios_vendor&.include?('Amazon EC2')
64
- return unless product_name
65
-
66
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
67
-
68
- nil
69
- end
70
-
71
- def check_lspci
72
- @log.debug('Checking lspci')
73
- Facter::Resolvers::Lspci.resolve(:vm)
74
- end
75
20
  end
76
21
  end
77
22
  end
@@ -27,7 +27,7 @@ module Facts
27
27
  fact_value = {}
28
28
  fact_value['full'] = version
29
29
  fact_value['major'] = versions[0]
30
- fact_value['minor'] = versions[1].gsub(/^0([1-9])/, '\1') if versions[1]
30
+ fact_value['minor'] = versions[1] if versions[1]
31
31
  fact_value
32
32
  end
33
33
  end
@@ -24,7 +24,7 @@ module Facts
24
24
 
25
25
  def add_legacy_facts(disks, facts)
26
26
  disks.each do |disk_name, disk_info|
27
- facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_size", disk_info[:size_bytes].to_s, :legacy))
27
+ facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_size", disk_info[:size_bytes], :legacy))
28
28
  facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_vendor", disk_info[:vendor], :legacy))
29
29
  end
30
30
  end
@@ -28,7 +28,7 @@ module Facts
28
28
  end
29
29
 
30
30
  resolved_facts << Facter::ResolvedFact.new('solaris_zones.zones', zones)
31
- resolved_facts << Facter::ResolvedFact.new('zones', results.count.to_s, :legacy)
31
+ resolved_facts << Facter::ResolvedFact.new('zones', results.count, :legacy)
32
32
 
33
33
  resolved_facts.flatten
34
34
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ class VirtualDetector
5
+ def initialize
6
+ @log = Facter::Log.new(self)
7
+ end
8
+
9
+ def platform # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
10
+ fact_value = check_docker_lxc || check_dmi || check_gce || retrieve_from_virt_what || check_vmware
11
+ fact_value ||= check_open_vz || check_vserver || check_xen || check_other_facts || check_lspci || 'physical'
12
+
13
+ fact_value
14
+ end
15
+
16
+ def check_docker_lxc
17
+ @log.debug('Checking Docker and LXC')
18
+ Facter::Resolvers::Containers.resolve(:vm)
19
+ end
20
+
21
+ def check_dmi
22
+ @log.debug('Checking DMI')
23
+ vendor = Facter::Resolvers::DmiDecode.resolve(:vendor)
24
+ @log.debug("dmi detected vendor: #{vendor}")
25
+ return 'kvm' if vendor =~ /Amazon/
26
+
27
+ 'xen' if vendor =~ /Xen/
28
+ end
29
+
30
+ def check_gce
31
+ @log.debug('Checking GCE')
32
+ bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
33
+ 'gce' if bios_vendor&.include?('Google')
34
+ end
35
+
36
+ def check_vmware
37
+ @log.debug('Checking VMware')
38
+ Facter::Resolvers::Vmware.resolve(:vm)
39
+ end
40
+
41
+ def retrieve_from_virt_what
42
+ @log.debug('Checking virtual_what')
43
+ Facter::Resolvers::VirtWhat.resolve(:vm)
44
+ end
45
+
46
+ def check_open_vz
47
+ @log.debug('Checking OpenVZ')
48
+ Facter::Resolvers::OpenVz.resolve(:vm)
49
+ end
50
+
51
+ def check_vserver
52
+ @log.debug('Checking VServer')
53
+ Facter::Resolvers::VirtWhat.resolve(:vserver)
54
+ end
55
+
56
+ def check_xen
57
+ @log.debug('Checking XEN')
58
+ Facter::Resolvers::Xen.resolve(:vm)
59
+ end
60
+
61
+ def check_other_facts
62
+ @log.debug('Checking others')
63
+ product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
64
+ bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
65
+ return 'kvm' if bios_vendor&.include?('Amazon EC2')
66
+ return unless product_name
67
+
68
+ Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
69
+
70
+ nil
71
+ end
72
+
73
+ def check_lspci
74
+ @log.debug('Checking lspci')
75
+ Facter::Resolvers::Lspci.resolve(:vm)
76
+ end
77
+ end
78
+ end
@@ -7,11 +7,13 @@ module Facter
7
7
  module Benchmarking
8
8
  class Timer
9
9
  class << self
10
- def measure(fact_name)
10
+ def measure(fact_name, prefix_message = '')
11
11
  if Options[:timing]
12
12
  time = Benchmark.measure { yield }
13
13
 
14
- puts "fact `#{fact_name}`, took: #{time.format('%r')} seconds"
14
+ log = "fact '#{fact_name}', took: #{time.format('%r')} seconds"
15
+ prefix_message = "#{prefix_message} " unless prefix_message.empty?
16
+ puts "#{prefix_message}#{log}"
15
17
  else
16
18
  yield
17
19
  end
@@ -1,14 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'thor'
5
+
4
6
  module Facter
5
7
  class Cli < Thor
6
- check_unknown_options!
7
-
8
8
  class_option :color,
9
9
  type: :boolean,
10
10
  desc: 'Enable color output.'
11
11
 
12
+ class_option :no_color,
13
+ type: :boolean,
14
+ desc: 'Disable color output.'
15
+
12
16
  class_option :config,
13
17
  aliases: '-c',
14
18
  type: :string,
@@ -29,17 +33,6 @@ module Facter
29
33
  repeatable: true,
30
34
  desc: 'A directory to use for external facts.'
31
35
 
32
- class_option :help,
33
- hide: true,
34
- aliases: '-h',
35
- type: :boolean,
36
- desc: 'Print this help message.'
37
-
38
- class_option :man,
39
- hide: true,
40
- type: :boolean,
41
- desc: 'Display manual.'
42
-
43
36
  class_option :hocon,
44
37
  type: :boolean,
45
38
  desc: 'Output in Hocon format.'
@@ -49,36 +42,28 @@ module Facter
49
42
  type: :boolean,
50
43
  desc: 'Output in JSON format.'
51
44
 
52
- class_option :list_block_groups,
53
- type: :boolean,
54
- desc: 'List the names of all blockable fact groups.'
55
-
56
- class_option :list_cache_groups,
57
- type: :boolean,
58
- desc: 'List the names of all cacheable fact groups.'
59
-
60
45
  class_option :log_level,
61
46
  aliases: '-l',
62
47
  type: :string,
63
48
  desc: 'Set logging level. Supported levels are: none, trace, debug, info, warn, error, and fatal.'
64
49
 
65
- class_option :block,
50
+ class_option :no_block,
66
51
  type: :boolean,
67
52
  desc: 'Disable fact blocking.'
68
53
 
69
- class_option :cache,
54
+ class_option :no_cache,
70
55
  type: :boolean,
71
56
  desc: 'Disable loading and refreshing facts from the cache'
72
57
 
73
- class_option :custom_facts,
58
+ class_option :no_custom_facts,
74
59
  type: :boolean,
75
60
  desc: 'Disable custom facts.'
76
61
 
77
- class_option :external_facts,
62
+ class_option :no_external_facts,
78
63
  type: :boolean,
79
64
  desc: 'Disable external facts.'
80
65
 
81
- class_option :ruby,
66
+ class_option :no_ruby,
82
67
  type: :boolean,
83
68
  desc: 'Disable loading Ruby, facts requiring Ruby, and custom facts.'
84
69
 
@@ -94,6 +79,11 @@ module Facter
94
79
  type: :boolean,
95
80
  desc: 'Show legacy facts when querying all facts.'
96
81
 
82
+ class_option :puppet,
83
+ type: :boolean,
84
+ aliases: '-p',
85
+ desc: 'Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.'
86
+
97
87
  class_option :yaml,
98
88
  aliases: '-y',
99
89
  type: :boolean,
@@ -103,17 +93,12 @@ module Facter
103
93
  type: :boolean,
104
94
  desc: 'Enable more aggressive error reporting.'
105
95
 
106
- class_option :puppet,
107
- type: :boolean,
108
- aliases: '-p',
109
- desc: 'Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.'
110
-
111
96
  class_option :timing,
112
97
  type: :boolean,
113
98
  aliases: '-t',
114
99
  desc: 'Show how much time it took to resolve each fact'
115
100
 
116
- desc '--man', 'Manual', hide: true
101
+ desc '--man', 'Display manual.', hide: true
117
102
  map ['--man'] => :man
118
103
  def man(*args)
119
104
  require 'erb'
@@ -126,7 +111,6 @@ module Facter
126
111
  end
127
112
 
128
113
  desc 'query', 'Default method', hide: true
129
- desc '[options] [query] [query] [...]', ''
130
114
  def query(*args)
131
115
  output, status = Facter.to_user_output(@options, *args)
132
116
  puts output
@@ -135,13 +119,21 @@ module Facter
135
119
  exit status
136
120
  end
137
121
 
122
+ desc 'arg_parser', 'Parse arguments', hide: true
123
+ def arg_parser(*args)
124
+ # ignore unknown options
125
+ args.reject! { |arg| arg.start_with?('-') }
126
+
127
+ Facter.values(@options, args)
128
+ end
129
+
138
130
  desc '--version, -v', 'Print the version', hide: true
139
131
  map ['--version', '-v'] => :version
140
- def version
132
+ def version(*_args)
141
133
  puts Facter::VERSION
142
134
  end
143
135
 
144
- desc '--list-block-groups', 'List block groups', hide: true
136
+ desc '--list-block-groups', 'List block groups'
145
137
  map ['--list-block-groups'] => :list_block_groups
146
138
  def list_block_groups(*args)
147
139
  options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
@@ -153,7 +145,7 @@ module Facter
153
145
  puts block_groups
154
146
  end
155
147
 
156
- desc '--list-cache-groups', 'List cache groups', hide: true
148
+ desc '--list-cache-groups', 'List cache groups'
157
149
  map ['--list-cache-groups'] => :list_cache_groups
158
150
  def list_cache_groups(*args)
159
151
  options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
@@ -165,6 +157,61 @@ module Facter
165
157
  puts cache_groups
166
158
  end
167
159
 
160
+ desc 'help', 'Help for all arguments'
161
+ def help(*args)
162
+ help_string = +''
163
+ help_string << help_header(args)
164
+ help_string << add_class_options_to_help
165
+ help_string << add_commands_to_help
166
+
167
+ puts help_string
168
+ end
169
+
170
+ no_commands do
171
+ def help_header(_args)
172
+ path = File.join(File.dirname(__FILE__), '../../')
173
+
174
+ Util::FileHelper.safe_read("#{path}fixtures/facter_help_header")
175
+ end
176
+
177
+ IGNORE_OPTIONS = %w[log_level color no_color].freeze
178
+
179
+ def add_class_options_to_help
180
+ help_class_options = +''
181
+ class_options = Cli.class_options
182
+ class_options.each do |class_option|
183
+ option = class_option[1]
184
+ next if option.hide
185
+
186
+ help_class_options << build_option(option.name, option.aliases, option.description)
187
+ end
188
+
189
+ help_class_options
190
+ end
191
+
192
+ def add_commands_to_help
193
+ help_command_options = +''
194
+ Cli.commands
195
+ .select { |_k, command_class| command_class.instance_of?(Thor::Command) }
196
+ .each do |_k, command|
197
+ help_command_options << build_option(command['name'], [], command['description'])
198
+ end
199
+
200
+ help_command_options
201
+ end
202
+
203
+ def build_option(name, aliases, description)
204
+ help_option = +''
205
+ help_option << aliases.join(',').rjust(10)
206
+ help_option << ' '
207
+ help_option << "[--#{name}]".ljust(30)
208
+ help_option << " #{description}"
209
+ help_option << "\n"
210
+
211
+ help_option
212
+ end
213
+ end
214
+
168
215
  def self.exit_on_failure?
169
216
  true
170
217
  end