Permalink
Browse files

Do the Murdock!

  • Loading branch information...
1 parent c9492d8 commit a8b90b35f153741ba28943b14c796d13903f724c @imdario committed Jul 15, 2010
Showing with 154 additions and 144 deletions.
  1. +1 −1 .project
  2. +3 −3 .settings/org.sonar.ide.eclipse.prefs
  3. +9 −10 pom.xml
  4. +0 −29 src/main/java/ba/stascus/exceptions/StascusException.java
  5. +0 −6 src/main/java/ba/stascus/exceptions/StascusExceptionType.java
  6. +15 −14 src/main/java/{ba/stascus/Stascus.java → hm/murdock/Murdock.java}
  7. +13 −11 src/main/java/{ba/stascus → hm/murdock}/cli/Router.java
  8. +3 −3 src/main/java/{ba/stascus → hm/murdock}/exceptions/ActionException.java
  9. +3 −3 src/main/java/{ba/stascus → hm/murdock}/exceptions/ConfigurationException.java
  10. +3 −2 src/main/java/{ba/stascus → hm/murdock}/exceptions/MultipleRoutingException.java
  11. +29 −0 src/main/java/hm/murdock/exceptions/MurdockException.java
  12. +6 −0 src/main/java/hm/murdock/exceptions/MurdockExceptionType.java
  13. +3 −3 src/main/java/{ba/stascus → hm/murdock}/exceptions/RoutingException.java
  14. +5 −4 src/main/java/{ba/stascus → hm/murdock}/modules/Action.java
  15. +4 −3 src/main/java/{ba/stascus → hm/murdock}/modules/ActionParameter.java
  16. +4 −3 src/main/java/{ba/stascus → hm/murdock}/modules/ActionParameters.java
  17. +2 −2 src/main/java/{ba/stascus → hm/murdock}/modules/Alias.java
  18. +1 −1 src/main/java/{ba/stascus → hm/murdock}/modules/CanOmitFlag.java
  19. +5 −4 src/main/java/{ba/stascus → hm/murdock}/modules/Help.java
  20. +1 −1 src/main/java/{ba/stascus → hm/murdock}/modules/LeftOver.java
  21. +2 −2 src/main/java/{ba/stascus → hm/murdock}/modules/Module.java
  22. +1 −1 src/main/java/{ba/stascus → hm/murdock}/modules/Optional.java
  23. +9 −7 src/main/java/{ba/stascus → hm/murdock}/utils/Context.java
  24. +1 −1 src/main/java/{ba/stascus → hm/murdock}/utils/ContextProperty.java
  25. +3 −3 src/main/java/{ba/stascus → hm/murdock}/utils/Utils.java
  26. +8 −8 src/test/java/{ba/stascus → hm/murdock}/test/cli/RouterTest.java
  27. +7 −6 src/test/java/{ba/stascus → hm/murdock}/test/modules/ActionTest.java
  28. +8 −8 src/test/java/{ba/stascus → hm/murdock}/test/utils/ContextTest.java
  29. +5 −5 src/test/java/{ba/stascus → hm/murdock}/test/utils/UtilsTest.java
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>stascus</name>
+ <name>murdock</name>
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects>
</projects>
@@ -1,4 +1,4 @@
-#Sat Jul 10 10:47:41 CEST 2010
+#Thu Jul 15 20:21:01 CEST 2010
eclipse.preferences.version=1
-projectArtifactId=stascus
-projectGroupId=ba.stascus
+projectArtifactId=murdock
+projectGroupId=hm.murdock
View
19 pom.xml
@@ -2,13 +2,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>ba.stascus</groupId>
- <artifactId>stascus</artifactId>
+ <groupId>hm.murdock</groupId>
+ <artifactId>murdock</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
- <name>stascus</name>
- <url>http://maven.apache.org</url>
+ <name>murdock</name>
+ <description>Howling mad command line app framework</description>
+ <url>http://github.com/imdario/murdock</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -60,12 +61,6 @@
<artifactId>reflections</artifactId>
<version>0.9.5-RC1</version>
</dependency>
- <dependency>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer-parent</artifactId>
- <version>2.2.1</version>
- <type>pom</type>
- </dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
@@ -79,6 +74,10 @@
</dependency>
</dependencies>
+ <organization>
+ <name>I'm Dario</name>
+ <url>http://www.dario.im</url>
+ </organization>
<build>
<plugins>
<plugin>
@@ -1,29 +0,0 @@
-package ba.stascus.exceptions;
-
-public abstract class StascusException extends Exception {
-
- private static final long serialVersionUID = -951449883507589064L;
-
- private StascusExceptionType type;
-
- protected StascusException() {
- super();
- }
-
- public StascusException(StascusExceptionType type, Object... args) {
- super(type.getMessage(args));
- this.type = type;
- }
-
- public StascusException(StascusExceptionType type, Throwable cause,
- Object... args) {
- super(type.getMessage(args), cause);
- this.type = type;
- }
-
- protected final StascusExceptionType getInnerType() {
- return this.type;
- }
-
- public abstract StascusExceptionType getType();
-}
@@ -1,6 +0,0 @@
-package ba.stascus.exceptions;
-
-public interface StascusExceptionType {
-
- String getMessage(Object... args);
-}
@@ -1,15 +1,16 @@
-package ba.stascus;
+package hm.murdock;
+
+import hm.murdock.cli.Router;
+import hm.murdock.exceptions.ActionException;
+import hm.murdock.exceptions.ConfigurationException;
+import hm.murdock.exceptions.MultipleRoutingException;
+import hm.murdock.exceptions.RoutingException;
+import hm.murdock.modules.Action;
+import hm.murdock.utils.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ba.stascus.cli.Router;
-import ba.stascus.exceptions.ActionException;
-import ba.stascus.exceptions.ConfigurationException;
-import ba.stascus.exceptions.MultipleRoutingException;
-import ba.stascus.exceptions.RoutingException;
-import ba.stascus.modules.Action;
-import ba.stascus.utils.Context;
/**
* B.A. Stascus: I'm gonna end this, fool!
@@ -29,21 +30,21 @@
* @author Dario (i@dario.im)
*
*/
-public final class Stascus {
+public final class Murdock {
public static final String VERSION = "0.0.1";
- public static final String NAME = Stascus.class.getSimpleName();
+ public static final String NAME = Murdock.class.getSimpleName();
private final Router router;
private final Logger logger;
- public Stascus() throws ConfigurationException {
+ public Murdock() throws ConfigurationException {
Context context = new Context();
this.router = new Router(context);
- this.logger = LoggerFactory.getLogger(Stascus.NAME);
+ this.logger = LoggerFactory.getLogger(Murdock.NAME);
}
/**
@@ -71,7 +72,7 @@ public void delegate(String... args) {
}
public static void main(String... args) throws ConfigurationException {
- Stascus stascus = new Stascus();
- stascus.delegate(args);
+ Murdock murdock = new Murdock();
+ murdock.delegate(args);
}
}
@@ -1,25 +1,27 @@
-package ba.stascus.cli;
+package hm.murdock.cli;
+
+import hm.murdock.Murdock;
+import hm.murdock.exceptions.ActionException;
+import hm.murdock.exceptions.MultipleRoutingException;
+import hm.murdock.exceptions.RoutingException;
+import hm.murdock.exceptions.RoutingException.RoutingExceptionType;
+import hm.murdock.modules.Action;
+import hm.murdock.modules.Module;
+import hm.murdock.utils.Context;
+import hm.murdock.utils.Utils;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ba.stascus.Stascus;
-import ba.stascus.exceptions.ActionException;
-import ba.stascus.exceptions.MultipleRoutingException;
-import ba.stascus.exceptions.RoutingException;
-import ba.stascus.exceptions.RoutingException.RoutingExceptionType;
-import ba.stascus.modules.Action;
-import ba.stascus.modules.Module;
-import ba.stascus.utils.Context;
-import ba.stascus.utils.Utils;
/**
* Handles command-line args to the corresponding module's action.
@@ -70,7 +72,7 @@ public Router(Context context) {
nameActions.put(action.toString(), action);
actions.put(name, nameActions);
} catch (ActionException e) {
- Logger logger = LoggerFactory.getLogger(Stascus.NAME);
+ Logger logger = LoggerFactory.getLogger(Murdock.NAME);
logger.warn("Ignoring action " + method.getName(), e);
}
}
@@ -1,12 +1,12 @@
-package ba.stascus.exceptions;
+package hm.murdock.exceptions;
/**
* Represents an exception while loading or calling a module.
*
* @author Dario (i@dario.im)
*
*/
-public final class ActionException extends StascusException {
+public final class ActionException extends MurdockException {
private static final long serialVersionUID = -465468986842430155L;
@@ -19,7 +19,7 @@ public ActionException(ActionExceptionType type, Throwable cause,
super(type, cause, args);
}
- public enum ActionExceptionType implements StascusExceptionType {
+ public enum ActionExceptionType implements MurdockExceptionType {
UNABLE_INVOKE, UNABLE_ACCESS, CLASS_NOT_SUPPORTED, UNABLE_ASSIGN_SHORT_OPTION, INVOKING_ERROR;
public String getMessage(Object... args) {
@@ -1,12 +1,12 @@
-package ba.stascus.exceptions;
+package hm.murdock.exceptions;
/**
* Represents an exception while loading, updating or saving configuration.
*
* @author Dario (i@dario.im)
*
*/
-public final class ConfigurationException extends StascusException {
+public final class ConfigurationException extends MurdockException {
private static final long serialVersionUID = -712453084854927282L;
@@ -20,7 +20,7 @@ public ConfigurationException(ConfigurationExceptionType type,
super(type, cause, args);
}
- public enum ConfigurationExceptionType implements StascusExceptionType {
+ public enum ConfigurationExceptionType implements MurdockExceptionType {
UNABLE_CREATE_HOME, INVALID_FORMAT_CONFIG, UNABLE_ACCESS_CONFIG, UNABLE_READ_CONFIG, UNABLE_WRITE_CONFIG;
public String getMessage(Object... args) {
@@ -1,8 +1,9 @@
-package ba.stascus.exceptions;
+package hm.murdock.exceptions;
+
+import hm.murdock.modules.Action;
import java.util.Map;
-import ba.stascus.modules.Action;
/**
* Represents an exception while loading or calling a module.
@@ -0,0 +1,29 @@
+package hm.murdock.exceptions;
+
+public abstract class MurdockException extends Exception {
+
+ private static final long serialVersionUID = -951449883507589064L;
+
+ private MurdockExceptionType type;
+
+ protected MurdockException() {
+ super();
+ }
+
+ public MurdockException(MurdockExceptionType type, Object... args) {
+ super(type.getMessage(args));
+ this.type = type;
+ }
+
+ public MurdockException(MurdockExceptionType type, Throwable cause,
+ Object... args) {
+ super(type.getMessage(args), cause);
+ this.type = type;
+ }
+
+ protected final MurdockExceptionType getInnerType() {
+ return this.type;
+ }
+
+ public abstract MurdockExceptionType getType();
+}
@@ -0,0 +1,6 @@
+package hm.murdock.exceptions;
+
+public interface MurdockExceptionType {
+
+ String getMessage(Object... args);
+}
@@ -1,12 +1,12 @@
-package ba.stascus.exceptions;
+package hm.murdock.exceptions;
/**
* Represents an exception while loading or calling a module.
*
* @author Dario (i@dario.im)
*
*/
-public class RoutingException extends StascusException {
+public class RoutingException extends MurdockException {
private static final long serialVersionUID = -4855173328667224615L;
@@ -23,7 +23,7 @@ public RoutingException(RoutingExceptionType type, Throwable cause,
super(type, cause, args);
}
- public enum RoutingExceptionType implements StascusExceptionType {
+ public enum RoutingExceptionType implements MurdockExceptionType {
FOOL_ME, MISSING_ARGUMENTS, NOT_VALID_COMMAND, MULTIPLE_ROUTES;
public String getMessage(Object... args) {
@@ -1,12 +1,13 @@
-package ba.stascus.modules;
+package hm.murdock.modules;
+
+import hm.murdock.exceptions.ActionException;
+import hm.murdock.exceptions.ActionException.ActionExceptionType;
+import hm.murdock.utils.Context;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Locale;
-import ba.stascus.exceptions.ActionException;
-import ba.stascus.exceptions.ActionException.ActionExceptionType;
-import ba.stascus.utils.Context;
/**
* Represents an action provided by a module. It is associated to a method,
@@ -1,4 +1,7 @@
-package ba.stascus.modules;
+package hm.murdock.modules;
+
+import hm.murdock.exceptions.ActionException;
+import hm.murdock.exceptions.ActionException.ActionExceptionType;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
@@ -8,8 +11,6 @@
import java.util.HashSet;
import java.util.Set;
-import ba.stascus.exceptions.ActionException;
-import ba.stascus.exceptions.ActionException.ActionExceptionType;
public class ActionParameter {
private AccessibleObject deserializer;
@@ -1,4 +1,7 @@
-package ba.stascus.modules;
+package hm.murdock.modules;
+
+import hm.murdock.exceptions.ActionException;
+import hm.murdock.exceptions.ActionException.ActionExceptionType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
@@ -15,8 +18,6 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import ba.stascus.exceptions.ActionException;
-import ba.stascus.exceptions.ActionException.ActionExceptionType;
import com.thoughtworks.paranamer.BytecodeReadingParanamer;
import com.thoughtworks.paranamer.Paranamer;
@@ -1,6 +1,6 @@
-package ba.stascus.modules;
+package hm.murdock.modules;
-import ba.stascus.utils.Context;
+import hm.murdock.utils.Context;
/**
* TODO
@@ -1,4 +1,4 @@
-package ba.stascus.modules;
+package hm.murdock.modules;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Oops, something went wrong.

0 comments on commit a8b90b3

Please sign in to comment.