<commit_before># Print the given application's sdef(5).

require 'rbosa'
require 'rexml/document'

def usage
    STDERR.puts <<-EOS
Usage: #{$0} [--name | --path | --bundle_id | --signature] ...
Examples:
    #{$0} --name iTunes
    #{$0} --path /Applications/iTunes.app 
    #{$0} --bundle_id com.apple.iTunes 
    #{$0} --signature hook
EOS
    exit 1
end

usage unless ARGV.length == 2 

msg = case ARGV.first
    when '--name'
        :app_with_name
    when '--path'
        :app_with_path
    when '--bundle_id'
        :app_with_bundle_id
    when '--signature'
        :app_with_signature
    else
        usage
end

app = OSA.send(msg, ARGV.last)
doc = REXML::Document.new(app.sdef)
doc.write(STDOUT, 1)
puts ""<commit_msg>better XML formatting<commit_after># Print the given application's sdef(5).

require 'rbosa'
require 'rexml/document'

def usage
    STDERR.puts <<-EOS
Usage: #{$0} [--name | --path | --bundle_id | --signature] ...
Examples:
    #{$0} --name iTunes
    #{$0} --path /Applications/iTunes.app 
    #{$0} --bundle_id com.apple.iTunes 
    #{$0} --signature hook
EOS
    exit 1
end

usage unless ARGV.length == 2 

msg = case ARGV.first
    when '--name'
        :app_with_name
    when '--path'
        :app_with_path
    when '--bundle_id'
        :app_with_bundle_id
    when '--signature'
        :app_with_signature
    else
        usage
end

app = OSA.send(msg, ARGV.last)
doc = REXML::Document.new(app.sdef)
doc.write(STDOUT, 0)
puts ""
{'fraction_non_alphanumeric': 0.15217391304347827, 'fraction_numerical': 0.012228260869565218, 'mean_word_length': 2.482269503546099, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5850391', 'n_tokens_mistral': 581, 'n_tokens_neox': 538, 'n_words': 136}