devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1721073 - in /devicemap/trunk/clients/1.0/java: console/NOTICE console/pom.xml console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java pom.xml
Date Sun, 20 Dec 2015 21:57:54 GMT
Author: wkeil
Date: Sun Dec 20 21:57:54 2015
New Revision: 1721073

URL: http://svn.apache.org/viewvc?rev=1721073&view=rev
Log:
DMAP-186: Some arguments like debug/log won't work in Java Console 

Task-Url: https://issues.apache.org/jira/browse/DMAP-186

Modified:
    devicemap/trunk/clients/1.0/java/console/NOTICE
    devicemap/trunk/clients/1.0/java/console/pom.xml
    devicemap/trunk/clients/1.0/java/console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java
    devicemap/trunk/clients/1.0/java/pom.xml

Modified: devicemap/trunk/clients/1.0/java/console/NOTICE
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/console/NOTICE?rev=1721073&r1=1721072&r2=1721073&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/console/NOTICE (original)
+++ devicemap/trunk/clients/1.0/java/console/NOTICE Sun Dec 20 21:57:54 2015
@@ -1,8 +1,7 @@
 =============
 Bundled APIs:
 =============
-This module uses the Airlift Airline framework. 
-It is licensed under Apache 2 as well.
+This module uses Apache Commons CLI. 
 
-The source code of  Airline is available at
-https://github.com/airlift/airline
+The source code of Apache Commons CLI is available at
+https://commons.apache.org/proper/commons-cli/source-repository.html
\ No newline at end of file

Modified: devicemap/trunk/clients/1.0/java/console/pom.xml
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/console/pom.xml?rev=1721073&r1=1721072&r2=1721073&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/console/pom.xml (original)
+++ devicemap/trunk/clients/1.0/java/console/pom.xml Sun Dec 20 21:57:54 2015
@@ -41,8 +41,8 @@
 			<artifactId>devicemap-client</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>io.airlift</groupId>
-			<artifactId>airline</artifactId>
+			<groupId>commons-cli</groupId>
+			<artifactId>commons-cli</artifactId>
 		</dependency>
 		<dependency>
 			<groupId>junit</groupId>

Modified: devicemap/trunk/clients/1.0/java/console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java?rev=1721073&r1=1721072&r2=1721073&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java
(original)
+++ devicemap/trunk/clients/1.0/java/console/src/main/java/org/apache/devicemap/console/DeviceMapConsole.java
Sun Dec 20 21:57:54 2015
@@ -18,14 +18,6 @@
  */
 package org.apache.devicemap.console;
 
-import io.airlift.airline.Arguments;
-import io.airlift.airline.Cli;
-import io.airlift.airline.Cli.CliBuilder;
-import io.airlift.airline.Command;
-import io.airlift.airline.Help;
-import io.airlift.airline.Option;
-import io.airlift.airline.OptionType;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -34,6 +26,14 @@ import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
 import org.apache.devicemap.DeviceMapClient;
 import org.apache.devicemap.data.Device;
 import org.apache.devicemap.loader.LoaderOption;
@@ -42,14 +42,16 @@ import org.apache.devicemap.loader.impl.
 /**
  * @author Reza Naghibi
  * @author Werner Keil
- * @version 1.1.1
+ * @version 1.1.2
  */
 public class DeviceMapConsole {
 	private static final String APP_NAME = "DeviceMap Java Console";
-	private final static Logger LOG = Logger.getLogger(DeviceMapConsole.class.getName());
+	private static final String CLASS_NAME = DeviceMapConsole.class.getName();
+	private final static Logger LOG = Logger.getLogger(CLASS_NAME);
 
 	private static boolean isVerbose;
 
+	/*
 	static class ToolCommand implements Runnable {
 		@Option(type = OptionType.GLOBAL, name = "-v", description = "Verbose mode")
 		public boolean verbose;
@@ -92,25 +94,70 @@ public class DeviceMapConsole {
 			}
 		}
 	}
+	
+	*/
 
 	public static void main(String[] args) throws Exception {
 
 		System.out.println(APP_NAME + " "
 				+ DeviceMapConsole.class.getPackage().getImplementationVersion());
+	    CommandLine lvCmd = null;
+        HelpFormatter lvFormater = new HelpFormatter();
+        CommandLineParser lvParser = new BasicParser();
+        Options lvOptions = new Options();
 		
-		try {
-			@SuppressWarnings("unchecked")
-			CliBuilder<Runnable> builder = Cli.<Runnable>builder(DeviceMapConsole.class.getSimpleName())
-		                .withDescription("Unicode CLDR Importer Tool")
-		                .withDefaultCommand(Help.class)
-		                .withCommands(Help.class, Classify.class)
-		                //.withCommands(Help.class, Write.class)
-		                ;
-		        Cli<Runnable> toolParser = builder.build();
-		        toolParser.parse(args).run();	
-		} catch (Exception e) {
-			LOG.severe(e.getMessage());
-		}
+        Option lvClassify = new Option("c", "classify", true, "User Agent String to test");
+        Option lvHilfe = new Option("h", "help", false, "Show Help.");
+        Option lvName = new Option("u", true, "Load DeviceMap resouces from URL or \"default\"");
+        Option lvJar = new Option("j", true, "Load DeviceMap resouces from JAR file in classpath");
+        Option lverbose = new Option("v", "verbose", false, "Verbose mode.");
+        
+        lvOptions.addOption(lvClassify);
+        lvOptions.addOption(lvHilfe);
+        lvOptions.addOption(lvName);
+        lvOptions.addOption(lvJar);
+        lvOptions.addOption(lverbose);
+        
+       /* lvOptions.addOption(OptionBuilder
+                .withLongOpt("url")
+                .withArgName("URL")
+                .withDescription("Load DeviceMap resouces from URL or \"default\"")
+                .hasArg()
+                .create("u"));
+        
+        lvOptions.addOption(OptionBuilder
+        		.withLongOpt("classify")
+        		.withArgName("userAgent")
+        		.withDescription("User Agent String to test")
+        		//.isRequired()
+        		.create("c"));
+        */
+        
+        try {
+            lvCmd = lvParser.parse(lvOptions, args);
+
+            if (lvCmd.hasOption('h')) {
+                lvFormater.printHelp(CLASS_NAME, lvOptions);
+                return;
+            }
+            
+            if (lvCmd.hasOption('u')) {
+            	System.out.println("URL: " + lvCmd.getOptionObject('u'));
+            }
+            
+            if (lvCmd.hasOption('j')) {
+            	System.out.println("JAR: " + lvCmd.getOptionObject('j'));
+            }
+            
+            if (lvCmd.hasOption('c')) {
+            	System.out.println("UA: " + lvCmd.getOptionObject("classify"));
+            }
+
+        } catch (ParseException pvException) {
+            lvFormater.printHelp(CLASS_NAME, lvOptions);
+            System.out.println("Parse Error:" + pvException.getMessage());
+            return;
+        }
 		
 		/*
 		if (args.length == 0) {

Modified: devicemap/trunk/clients/1.0/java/pom.xml
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/pom.xml?rev=1721073&r1=1721072&r2=1721073&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/pom.xml (original)
+++ devicemap/trunk/clients/1.0/java/pom.xml Sun Dec 20 21:57:54 2015
@@ -52,6 +52,11 @@
 				<version>${project.version}</version>
 			</dependency>
 			<dependency>
+				<groupId>commons-cli</groupId>
+				<artifactId>commons-cli</artifactId>
+				<version>1.3.1</version>
+			</dependency>
+			<dependency>
 				<groupId>io.airlift</groupId>
 				<artifactId>airline</artifactId>
 				<version>0.7</version>



Mime
View raw message