Hey, Provided patch works flawlessly. I also agree that we should consider renaming -a and -u options. However, nothing reasonable and *short* comes to me at the moment.
Just one thing - if we decide to add the 'ignore selected types of opportunities' option from #738169, we should make it apply user made selections even if --uninstalled option is used. In attached patch, I have merged --uninstalled option form #738170 with ignore from #738169, so both options can be used either separately or simultaneously. Regards, T.
diff --git a/bin/how-can-i-help b/bin/how-can-i-help index 987cf8e..add808c 100755 --- a/bin/how-can-i-help +++ b/bin/how-can-i-help @@ -33,6 +33,7 @@ CONFIGDIR = "#{HOME}/.config/how-can-i-help" SEEN_LOCAL = "#{CACHEDIR}/seen.json" CACHE = "#{CACHEDIR}/how-can-i-help.json.gz" PACKAGES = "#{CONFIGDIR}/packages" +IGNORED_TYPES = "#{CONFIGDIR}/ignored" ENV['LC_ALL'] = 'C.UTF-8' include Debian @@ -40,6 +41,7 @@ include Debian $quiet = false $all = false $proxy_url = ENV["HTTP_PROXY"] || ENV["http_proxy"] +$uninstalled = false optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show help') do @@ -60,6 +62,9 @@ optparse = OptionParser.new do |opts| $quiet = true end + opts.on('-u', '--uninstalled', 'show opportunities for uninstalled packages') do + $uninstalled = true + end end optparse.parse! @@ -121,10 +126,24 @@ if File.file?(PACKAGES) packages += additionals end +# add user defined ignored types +ignored_types = [] +if File.file?(IGNORED_TYPES) + selected_type = File.read(IGNORED_TYPES).gsub(/\s+/m, ' ').strip.split(" ") + ignored_types += selected_type +end + helpitems_filtered = [] helpitems.each do |hi| next if (not $all) and seen.include?(hi['hash']) - if hi['type'] == 'wnpp' + next if ignored_types.include?(hi['type']) + if $uninstalled + if hi['type'] == 'wnpp' + next if ignored_types.include?(hi['wnpptype']) + end + helpitems_filtered << hi + elsif hi['type'] == 'wnpp' + next if ignored_types.include?(hi['wnpptype']) if packages & hi['packages'] != [] helpitems_filtered << hi end
signature.asc
Description: OpenPGP digital signature