From 965df0bc2a456d4ebc7a5ee005d833b2ef7491ef Mon Sep 17 00:00:00 2001 From: Ivan Porto Carrero Date: Sun, 5 May 2013 21:57:14 -0700 Subject: [PATCH] Adds shell script for generating async scala client --- bin/scala-async.sh | 22 +++++++++++++++++++ project/build.properties | 2 +- .../codegen/ScalaAsyncClientGenerator.scala | 7 +++++- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100755 bin/scala-async.sh diff --git a/bin/scala-async.sh b/bin/scala-async.sh new file mode 100755 index 000000000000..6a8f75d5d292 --- /dev/null +++ b/bin/scala-async.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +cd $APP_DIR +ags="com.wordnik.swagger.codegen.ScalaAsyncClientGenerator $@" +./sbt "run-main $ags" diff --git a/project/build.properties b/project/build.properties index 21e2c5d75cc4..db255c253720 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.2 \ No newline at end of file +sbt.version=0.12.3 \ No newline at end of file diff --git a/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala b/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala index ffc367278861..201eed1e9e4e 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala @@ -75,13 +75,18 @@ object ScalaAsyncClientGenerator extends App { | For more info, visit: https://developers.helloreverb.com/swagger/ """.stripMargin - val opts = new AsycnClientGeneratorConf(args) + val opts = new AsycnClientGeneratorConf(if (args.nonEmpty) args else Array("--help")) val rootDir = new File(opts.projectRoot()) val codeDir = { val cd = opts.codeDir() if (cd.startsWith("/")) new File(cd) else new File(rootDir, cd) } + val resUrl = { + val r = opts.resourceUrl() + if (!r.startsWith("http") && !r.startsWith("file")) sys.props("fileMap") = r + r + } val cfg = SwaggerGenConfig( api = SwaggerApi(opts.name(), opts.resourceUrl(), opts.`package`(), apiKey = opts.apiKey.get), templateDir = new File(opts.templateDir()),