Navigation Menu

Skip to content

Commit

Permalink
Enabled specifying namespace when runinng reverse-scaffold command
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Mar 7, 2014
1 parent 4e4a158 commit 1721c22
Showing 1 changed file with 8 additions and 9 deletions.
Expand Up @@ -14,13 +14,10 @@ object ReverseScaffoldGenerator extends ReverseScaffoldGenerator
*/ */
trait ReverseScaffoldGenerator extends CodeGenerator { trait ReverseScaffoldGenerator extends CodeGenerator {


case class ParamTypeAndNullable(
paramType: ParamType,
nullable: Boolean)

protected def showUsage = { protected def showUsage = {
showSkinnyGenerator() showSkinnyGenerator()
println(""" Usage: sbt "task/run generate:reverse-scaffold table_name resources resource" """) 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() println()
} }


Expand All @@ -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) { if (args.size < 3) {
showUsage showUsage
return return
} }
try { 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.getOrElse(SkinnyEnv.Development))
System.setProperty(SkinnyEnv.PropertyKey, skinnyEnv)
DBSettings.initialize() DBSettings.initialize()


val columns = extractColumns(tableName) val columns = extractColumns(tableName)
Expand Down Expand Up @@ -90,7 +89,7 @@ trait ReverseScaffoldGenerator extends CodeGenerator {
} }
case _ => throw new IllegalArgumentException("Unknown template type: " + templateType) case _ => throw new IllegalArgumentException("Unknown template type: " + templateType)
} }
generator.run(Seq(resources, resource) ++ fields) generator.run(Seq(namespace, resources, resource) ++ fields)


} catch { } catch {
case e: Exception => case e: Exception =>
Expand Down

0 comments on commit 1721c22

Please sign in to comment.