Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enabled specifying namespace when runinng reverse-scaffold command

  • Loading branch information...
commit 1721c22a410db1218b479c9b1f603542da5fc70b 1 parent 4e4a158
Kazuhiro Sera seratch authored
17 task/src/main/scala/skinny/task/generator/ReverseScaffoldGenerator.scala
View
@@ -14,13 +14,10 @@ object ReverseScaffoldGenerator extends ReverseScaffoldGenerator
*/
trait ReverseScaffoldGenerator extends CodeGenerator {
- case class ParamTypeAndNullable(
- paramType: ParamType,
- nullable: Boolean)
-
protected def showUsage = {
showSkinnyGenerator()
println(""" Usage: sbt "task/run generate:reverse-scaffold table_name resources resource" """)
+ println(""" sbt "task/run generate:reverse-scaffold table_name namespace resources resource" """)
println()
}
@@ -30,16 +27,18 @@ trait ReverseScaffoldGenerator extends CodeGenerator {
""")
}
- def run(templateType: String, args: List[String]): Unit = {
+ def run(templateType: String, args: List[String], skinnyEnv: Option[String] = None): Unit = {
if (args.size < 3) {
showUsage
return
}
try {
- val (tableName, resources, resource) = (args(0), args(1), args(2))
+ val (tableName, namespace, resources, resource) = {
+ if (args.size >= 4) (args(0), args(1), args(2), args(3))
+ else (args(0), "", args(1), args(2))
+ }
- val skinnyEnv = if (args.size >= 4) args(3) else SkinnyEnv.Development
- System.setProperty(SkinnyEnv.PropertyKey, skinnyEnv)
+ System.setProperty(SkinnyEnv.PropertyKey, skinnyEnv.getOrElse(SkinnyEnv.Development))
DBSettings.initialize()
val columns = extractColumns(tableName)
@@ -90,7 +89,7 @@ trait ReverseScaffoldGenerator extends CodeGenerator {
}
case _ => throw new IllegalArgumentException("Unknown template type: " + templateType)
}
- generator.run(Seq(resources, resource) ++ fields)
+ generator.run(Seq(namespace, resources, resource) ++ fields)
} catch {
case e: Exception =>
Please sign in to comment.
Something went wrong with that request. Please try again.