Class: Facter::Cli
- Inherits:
-
Thor
- Object
- Thor
- Facter::Cli
- Defined in:
- lib/facter/framework/cli/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #arg_parser(*args) ⇒ Object
- #help(*args) ⇒ Object
- #list_block_groups(*args) ⇒ Object
- #list_cache_groups(*args) ⇒ Object
- #man(*args) ⇒ Object
- #puppet(*args) ⇒ Object
- #query(*args) ⇒ Object
- #version(*_args) ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
227 228 229 |
# File 'lib/facter/framework/cli/cli.rb', line 227 def self.exit_on_failure? true end |
Instance Method Details
#arg_parser(*args) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/facter/framework/cli/cli.rb', line 122 def arg_parser(*args) # ignore unknown options args.reject! { |arg| arg.start_with?('-') } Facter.values(@options, args) end |
#help(*args) ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/facter/framework/cli/cli.rb', line 172 def help(*args) help_string = +'' help_string << help_header(args) help_string << help_string << add_commands_to_help puts help_string end |
#list_block_groups(*args) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/facter/framework/cli/cli.rb', line 137 def list_block_groups(*args) = @options.map { |(k, v)| [k.to_sym, v] }.to_h Facter::Options.init_from_cli(, args) block_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join block_groups.gsub!(/:\s*\n/, "\n") puts block_groups end |
#list_cache_groups(*args) ⇒ Object
149 150 151 152 153 154 155 156 157 |
# File 'lib/facter/framework/cli/cli.rb', line 149 def list_cache_groups(*args) = @options.map { |(k, v)| [k.to_sym, v] }.to_h Facter::Options.init_from_cli(, args) cache_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join cache_groups.gsub!(/:\s*\n/, "\n") puts cache_groups end |
#man(*args) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/facter/framework/cli/cli.rb', line 102 def man(*args) require 'erb' = %w[block cache custom_facts external_facts] template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb') erb = ERB.new(File.read(template), nil, '-') erb.filename = template puts erb.result(binding) end |
#puppet(*args) ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/facter/framework/cli/cli.rb', line 161 def puppet(*args) Facter.puppet_facts output, status = Facter.to_user_output(@options, *args) puts output status = 1 if Facter::Log.errors? exit status end |
#query(*args) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/facter/framework/cli/cli.rb', line 113 def query(*args) output, status = Facter.to_user_output(@options, *args) puts output status = 1 if Facter::Log.errors? exit status end |