krysalis-version/src/java/org/krysalis/version/tool VersionToolImpl.java,1.1,1.2 VersionTool.java,1.1,1.2

[email protected]
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/tool
In directory sc8-pr-cvs1:/tmp/cvs-serv25982/src/java/org/krysalis/version/tool

Modified Files:
	VersionToolImpl.java VersionTool.java 
Log Message:
More docs
Command Line Tool
Removed CLI dependency (can't afford a core dependency for such little gain).

Index: VersionToolImpl.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/tool/VersionToolImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** VersionToolImpl.java	11 Feb 2003 23:46:26 -0000	1.1
--- VersionToolImpl.java	13 Feb 2003 15:46:26 -0000	1.2
***************
*** 59,62 ****
--- 59,65 ----
  import java.io.PrintWriter;
  
+ import org.krysalis.version.collecting.EntryCollection;
+ import org.krysalis.version.collecting.VersionCollector;
+ import org.krysalis.version.collecting.collectors.VersionBrandCollector;
  import org.krysalis.version.exception.VersionException;
  import org.krysalis.version.resolve.VersionMetadata;
***************
*** 90,93 ****
--- 93,118 ----
              m_out.println("Reference Not found: [" + id + "]");
  
+     }
+ 
+     public void displayAllVersions() throws VersionException {
+         VersionCollector vs = new VersionCollector();
+         EntryCollection collection = vs.collect();
+         if ((null != collection) && collection.hasEntries()) {
+             collection.sort();
+             collection.dump(m_out);
+         }
+         else
+             m_out.println("None found.");
+     }
+ 
+     public void displayAllBrandedVersions() throws VersionException {
+         VersionBrandCollector vb = new VersionBrandCollector();
+         EntryCollection collection = vb.collect();
+         if ((null != collection) && collection.hasEntries()) {
+             collection.sort();
+             collection.dump(m_out);
+         }
+         else
+             m_out.println("None found.");
      }
  }

Index: VersionTool.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/tool/VersionTool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** VersionTool.java	11 Feb 2003 23:46:26 -0000	1.1
--- VersionTool.java	13 Feb 2003 15:46:26 -0000	1.2
***************
*** 56,64 ****
  package org.krysalis.version.tool;
  
! import org.apache.commons.cli.CommandLine;
! import org.apache.commons.cli.CommandLineParser;
! import org.apache.commons.cli.Options;
! import org.apache.commons.cli.ParseException;
! import org.apache.commons.cli.PosixParser;
  
  /**
--- 56,64 ----
  package org.krysalis.version.tool;
  
! import org.krysalis.version.util.cli.CommandLine;
! import org.krysalis.version.util.cli.CommandLineParser;
! import org.krysalis.version.util.cli.Option;
! import org.krysalis.version.util.cli.Options;
! import org.krysalis.version.util.cli.ParseException;
  
  /**
***************
*** 69,93 ****
   */
  public class VersionTool {
      private static Options l_options;
      static {
          l_options = new Options();
!         l_options.addOption("v", "versionId", true, "version identifier");
      }
  
      public static void main(String[] args) {
          try {
!             CommandLineParser parser = new PosixParser();
              CommandLine cmd = parser.parse(l_options, args);
  
              VersionToolImpl tool = new VersionToolImpl(System.out);
-             String[] ids = cmd.getOptionValues('v');
-             if (null != ids)
-                 for (int i = 0; i < ids.length; i++) {
-                     tool.displayVersion(ids[i]);
-                 }
  
          }
          catch (ParseException exp) {
!             System.err.println("Parsing failed.  Reason: " + exp.getMessage());
          }
          catch (Exception exc) {
--- 69,143 ----
   */
  public class VersionTool {
+ 
+     private static final String VERSION_ID_SHORT = "i";
+     private static final String VERSION_ID_LONG = "versionId";
+ 
+     private static final String ALL_SHORT = "a";
+     private static final String ALL_LONG = "all";
+ 
+     private static final String BRAND_SHORT = "b";
+     private static final String BRAND_LONG = "brands";
+ 
+     private static final String VERBOSE_SHORT = "v";
+     private static final String VERBOSE_LONG = "verbose";
+ 
+     private static Option l_versionId;
+     private static Option l_all;
+     private static Option l_allBrands;
+     private static Option l_verbose;
      private static Options l_options;
      static {
+         l_versionId =
+             new Option(
+                 VERSION_ID_SHORT,
+                 VERSION_ID_LONG,
+                 true,
+                 "version identifier");
+         l_all = new Option(ALL_SHORT, ALL_LONG, false, "display all");
+         l_allBrands =
+             new Option(
+                 BRAND_SHORT,
+                 BRAND_LONG,
+                 false,
+                 "display all branded versions");
+         l_verbose = new Option(VERBOSE_SHORT, VERBOSE_LONG, false, "verbose");
+ 
          l_options = new Options();
!         l_options.addOption(l_all);
!         l_options.addOption(l_allBrands);
!         l_options.addOption(l_versionId);
!         l_options.addOption(l_verbose);
      }
  
      public static void main(String[] args) {
          try {
!             CommandLineParser parser = new CommandLineParser();
              CommandLine cmd = parser.parse(l_options, args);
  
              VersionToolImpl tool = new VersionToolImpl(System.out);
  
+             if (cmd.hasArguments()) {
+                 //:TODO: Usage..
+             }
+ 
+             if (cmd.isSet(l_verbose)) {
+             }
+ 
+             if (cmd.isSet(l_all)) {
+                 tool.displayAllVersions();
+             }
+             else if (cmd.isSet(l_allBrands)) {
+                 tool.displayAllBrandedVersions();
+             }
+             else {
+                 String[] ids = cmd.getOptionValues(l_versionId);
+                 if (null != ids)
+                     for (int i = 0; i < ids.length; i++) {
+                         tool.displayVersion(ids[i]);
+                     }
+             }
          }
          catch (ParseException exp) {
!             System.err.println("Command Line Error: " + exp.getMessage());
          }
          catch (Exception exc) {
***************
*** 95,98 ****
          }
      }
- 
  }
--- 145,147 ----




-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.