Skip to content

Commit

Permalink
Parse the command-line arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Mar 12, 2012
1 parent bf9b44a commit a9826d6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
19 changes: 19 additions & 0 deletions finagle-test.ipr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="IdProvider" IDEtalkID="389F4DD7991E712F738C72559202A45C" />
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
<option name="OPTION_HIERARCHY" value="true" />
<option name="OPTION_NAVIGATOR" value="true" />
<option name="OPTION_INDEX" value="true" />
<option name="OPTION_SEPARATE_INDEX" value="true" />
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
<option name="OPTION_DEPRECATED_LIST" value="true" />
<option name="OTHER_OPTIONS" value="" />
<option name="HEAP_SIZE" />
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
</component>
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
Expand Down Expand Up @@ -162,5 +180,6 @@
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
<component name="WebServicesPlugin" addRequiredLibraries="true" />
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,31 @@ object SearchEngineHttpProxy {
}

}

/**
* MongoDBStore companion object.
*/
object MongoDBStore {

/**
* Factory method to build a MongoDBStore object from command-line arguments.
*
* There are 3 arguments: a boolean to indicate if the stored data must be anonymized
* or not, a string for the MongoDB host address, and an integer to specify the TCP
* port number of the MongoDB server.
*
* With no arguments the defaults are: { true, 127.0.0.1, 27017 }.
*
* @param args the command-line arguments
* @return the store instance
* @throws IllegalArgumentException if the arguments do not match
*/
def apply(args: Array[String]): MongoDBStore = args.length match {
case 0 => new MongoDBStore()
case 3 => new MongoDBStore(args(0).toBoolean, args(1), args(2).toInt)
case _ => throw new IllegalArgumentException("Arguments must be: anonymize? (boolean), mongodb_host (string), mongodb_port (int)")
}
}

/**
* The good old entry point.
Expand All @@ -227,7 +252,7 @@ object SearchEngineHttpProxy {
val handleExceptions = new HandleExceptions
val proxyClient = new ProxyHttpClient

val mongodb = new MongoDBStore()
val mongodb = MongoDBStore(args)

val google = new GoogleSearch
val bing = new BingSearch
Expand Down

0 comments on commit a9826d6

Please sign in to comment.