Browse files

notes

  • Loading branch information...
1 parent 63e2922 commit 88bcfa6a4ce358e6534f8d09fc04a6dfd0c69cf6 @eed3si9n eed3si9n committed May 27, 2011
View
1 .gitignore
@@ -1,3 +1,4 @@
+src_managed
target
project/boot
lib_managed
View
38 notes/1.0.0.markdown
@@ -0,0 +1,38 @@
+## hello, world
+This is the initial release of scopt, a little command line parsing library.
+
+You can customize an *OptionParser* by passing in functions to process each option or argument.
+
+ val parser = new OptionParser("scopt") {
+ intOpt("f", "foo", "foo is an integer property", {v: Int => config.foo = v})
+ opt("o", "output", "<file>", "output is a string property", {v: String => config.bar = v})
+ booleanOpt("xyz", "xyz is a boolean property", {v: Boolean => config.xyz = v})
+ keyValueOpt("l", "lib", "<libname>", "<filename>", "load library <libname>",
+ {(key: String, value: String) => { config.libname = key; config.libfile = value } })
+ arg("<singlefile>", "<singlefile> is an argument", {v: String => config.whatnot = v})
+ // arglist("<file>...", "arglist allows variable number of arguments",
+ // {v: String => config.files = (v :: config.files).reverse })
+ }
+ if (parser.parse(args)) {
+ // do stuff
+ }
+ else {
+ // arguments are bad, usage message will have been displayed
+ }
+
+It handles various kinds of options such as optional, required, and key-value.
+From the above, it also automatically generates the usage text as follows:
+
+ Usage: scopt [options] <filename>
+
+ -f <value> | --foo <value>
+ foo is an integer property
+ -o <file> | --output <file>
+ output is a string property
+ --xyz <value>
+ xyz is a boolean property
+ -l:<libname>=<filename> | --lib:<libname>=<filename>
+ load library <libname>
+ <singlefile>
+ <singlefile> is an argument
+
View
1 notes/about.markdown
@@ -0,0 +1 @@
+scopt is a little command line options parsing library.
View
2 project/build/Scopt.scala
@@ -1,6 +1,6 @@
import sbt._
-class ScoptProject(info: ProjectInfo) extends DefaultProject(info) {
+class ScoptProject(info: ProjectInfo) extends DefaultProject(info) with posterous.Publish {
val scalaToolsNexusSnapshots = "Scala Tools Nexus Snapshots" at "http://nexus.scala-tools.org/content/repositories/snapshots/"
val scalaToolsNexusReleases = "Scala Tools Nexus Releases" at "http://nexus.scala-tools.org/content/repositories/releases/"
View
6 project/plugins/plugins.scala
@@ -0,0 +1,6 @@
+import sbt._
+
+class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
+ val t_repo = "t_repo" at "http://tristanhunt.com:8081/content/groups/public/"
+ val posterous = "net.databinder" % "posterous-sbt" % "0.1.4"
+}
View
3 project/plugins/project/build.properties
@@ -0,0 +1,3 @@
+#Project properties
+#Fri May 27 18:25:00 EDT 2011
+plugin.uptodate=true

0 comments on commit 88bcfa6

Please sign in to comment.