<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>trunk/as2api/ui</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">cli.rb</a></tt></td><td align="right" id="added">+80</td><td align="right" id="removed">-32</td><td nowrap="nowrap" align="center">314 -&gt; 315</td></tr>
</table>
<pre class="comment">
API-diff work in progress.  Committing now, as my laptop AC adapter has died.
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">trunk/as2api/ui</span><br />
<div class="fileheader"><big><b>cli.rb</b></big> <small id="info">314 -&gt; 315</small></div>
<pre class="diff"><small id="info">--- trunk/as2api/ui/cli.rb        2006-03-19 21:58:14 UTC (rev 314)
+++ trunk/as2api/ui/cli.rb        2006-03-19 21:59:43 UTC (rev 315)
@@ -13,7 +13,9 @@
</small></pre><pre class="diff" id="context"> require 'getoptlong'
 require 'set'
 require 'output/html/driver'
</pre><pre class="diff" id="added">+require 'api_diff'
</pre><pre class="diff" id="context"> require 'output/html/diff'
</pre><pre class="diff" id="added">+require 'output/diff/api_dump'
</pre><pre class="diff" id="context"> require 'localisation/xliff/driver.rb'
 require 'localisation/xliff/translation_loader.rb'
 
</pre><pre class="diff"><small id="info">@@ -23,7 +25,14 @@
</small></pre><pre class="diff" id="context"> 
 Conf = Struct.new(:output_dir,
                   :classpath,
</pre><pre class="diff" id="removed">-                  :oldrev_classpath,
</pre><pre class="diff" id="added">+                  :api_export,
+                  :api_name,
+                  :api_version,
+                  :diff_load_old,
+                  :diff_load_new,
+                  :diff_url_old,
+                  :diff_url_new,
+                  :do_diff,
</pre><pre class="diff" id="context">                   :package_filters,
                   :title,
                   :progress_listener,
</pre><pre class="diff"><small id="info">@@ -111,7 +120,13 @@
</small></pre><pre class="diff" id="context">       [ "--help",       "-h", GetoptLong::NO_ARGUMENT ],
       [ "--output-dir", "-d", GetoptLong::REQUIRED_ARGUMENT ],
       [ "--classpath",        GetoptLong::REQUIRED_ARGUMENT ],
</pre><pre class="diff" id="removed">-      [ "--oldrev-classpath", GetoptLong::REQUIRED_ARGUMENT ],
</pre><pre class="diff" id="added">+      [ "--api-export",       GetoptLong::NO_ARGUMENT ],
+      [ "--api-name",         GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--api-version",      GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--diff-load-old",    GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--diff-load-new",    GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--diff-url-old",     GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--diff-url-new",     GetoptLong::REQUIRED_ARGUMENT ],
</pre><pre class="diff" id="context">       [ "--title",            GetoptLong::REQUIRED_ARGUMENT ],
       [ "--progress",         GetoptLong::NO_ARGUMENT ],
       [ "--encoding",         GetoptLong::REQUIRED_ARGUMENT ],
</pre><pre class="diff"><small id="info">@@ -127,7 +142,6 @@
</small></pre><pre class="diff" id="context"> 
     conf = Conf.new
     conf.classpath = []
</pre><pre class="diff" id="removed">-    conf.oldrev_classpath = []
</pre><pre class="diff" id="context">     conf.package_filters = []
     conf.draw_diagrams = false
     conf.dot_exe = "dot"  #  i.e. assume 'dot' is in our PATH
</pre><pre class="diff"><small id="info">@@ -138,8 +152,20 @@
</small></pre><pre class="diff" id="context">           conf.output_dir = File.expand_path(arg)
         when "--classpath"
           conf.classpath.concat(arg.split(File::PATH_SEPARATOR))
</pre><pre class="diff" id="removed">-        when "--oldrev-classpath"
-          conf.oldrev_classpath.concat(arg.split(File::PATH_SEPARATOR))
</pre><pre class="diff" id="added">+        when "--api-export"
+          conf.api_export = true
+        when "--api-name"
+          conf.api_name = arg
+        when "--api-version"
+          conf.api_version = arg
+        when "--diff-load-old"
+          conf.diff_load_old = arg
+        when "--diff-load-new"
+          conf.diff_load_new = arg
+        when "--diff-url-old"
+          conf.diff_url_old = arg
+        when "--diff-url-new"
+          conf.diff_url_new = arg
</pre><pre class="diff" id="context">         when "--title"
           conf.title = arg
         when "--help"
</pre><pre class="diff"><small id="info">@@ -167,16 +193,24 @@
</small></pre><pre class="diff" id="context">           conf.xliff_export = arg
       end
     end
</pre><pre class="diff" id="removed">-    if ARGV.empty?
-      usage
-      error(_("No packages specified"))
-    end
</pre><pre class="diff" id="context">     if conf.xliff_import &amp;&amp; conf.xliff_export
       error(_("Options can't be used together: %s") % "--xliff-import --xliff-export")
     end
     if conf.xliff_export &amp;&amp; (conf.source_lang.nil? || conf.target_lang.nil?)
       error(_("Both --source-lang and --target-lang must be provided with --xliff-export"))
     end
</pre><pre class="diff" id="added">+    if conf.api_export &amp;&amp; (conf.api_name.nil? || conf.api_version.nil?)
+      error(_("Both --api-name and --api-version must be provided with --api-export"))
+    end
+    if conf.diff_load_old.nil? != conf.diff_load_new.nil?
+      error(_("--diff-load-old and --diff-load-new must appear together"))
+    elsif conf.diff_load_old &amp;&amp; conf.diff_load_new
+      conf.do_diff = true
+    end
+    if ARGV.empty? &amp;&amp; !conf.do_diff
+      usage
+      error(_("No packages specified"))
+    end
</pre><pre class="diff" id="context">     ARGV.each do |package_spec|
       conf.package_filters &lt;&lt; to_filter(package_spec)
     end
</pre><pre class="diff"><small id="info">@@ -262,33 +296,47 @@
</small></pre><pre class="diff" id="context">     generate_xliff(@conf, type_aggregator)
   end
 
</pre><pre class="diff" id="added">+  def api_export(type_aggregator)
+    generate_api_dump(@conf, type_aggregator)
+  end
+
+  def do_api_diff
+puts "Loading old API..."
+    old_type_agregator, old_api_name, old_api_version = load_api_dump(@conf.diff_load_old)
+puts "Loading new API..."
+    new_type_agregator, new_api_name, new_api_version = load_api_dump(@conf.diff_load_new)
+    if old_api_name != new_api_name
+      warn(_("API names differ: #{old_api_name.inspect} #{new_api_name.inspect}"))
+    end
+    diff = APIDiff.new
+puts "Calculating API changes..."
+    api_changes = diff.diff(old_type_agregator, new_type_agregator)
+
+    generate_diffs(@conf, api_changes)
+  end
+
</pre><pre class="diff" id="context">   def main
     @conf = parse_opts
</pre><pre class="diff" id="removed">-    files = find_sources(@conf.classpath)
-    error(_("No source files matching specified packages")) if files.empty?
-    type_agregator = parse_all(files)
-    if @conf.xliff_import
-      xliff_import(type_agregator)
-    end
-    type_resolver = TypeResolver.new(@conf.classpath)
-    type_resolver.resolve_types(type_agregator)
-    if @conf.xliff_export
-      xliff_export(type_agregator)
</pre><pre class="diff" id="added">+    if @conf.do_diff
+      do_api_diff
</pre><pre class="diff" id="context">     else
</pre><pre class="diff" id="removed">-      document_types(@conf, type_agregator)
</pre><pre class="diff" id="added">+      files = find_sources(@conf.classpath)
+      error(_("No source files matching specified packages")) if files.empty?
+      type_agregator = parse_all(files)
+      if @conf.xliff_import
+        xliff_import(type_agregator)
+      end
+      type_resolver = TypeResolver.new(@conf.classpath)
+      type_resolver.resolve_types(type_agregator)
+      if @conf.api_export
+        api_export(type_agregator)
+      end
+      if @conf.xliff_export
+        xliff_export(type_agregator)
+      else
+        document_types(@conf, type_agregator)
+      end
</pre><pre class="diff" id="context">     end
</pre><pre class="diff" id="removed">-
-    # TODO: remove this hackery
-    unless @conf.oldrev_classpath.empty?
-      old_files = find_sources(@conf.oldrev_classpath)
-      error(_("No source files matching specified packages in oldrev-classpath")) if old_files.empty?
-      old_type_agregator = parse_all(old_files, @conf.oldrev_classpath)
-      old_type_agregator.resolve_types
-      diff = APIDiff.new
-      api_changes = diff.diff(old_type_agregator, type_agregator)
-
-      generate_diffs(@conf, api_changes)
-    end
</pre><pre class="diff" id="context">   end
 
   def usage
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.11</small></center>
</body></html>