From 57879c7c00d8f0d10510340864a5c0d0a5b88e43 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Mon, 27 Mar 2017 01:37:11 +0200 Subject: [PATCH 1/2] Add an optional baseDirectory parameter to run() --- app/src/main/scala/giter8.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/scala/giter8.scala b/app/src/main/scala/giter8.scala index 579a9b77..09bcc527 100644 --- a/app/src/main/scala/giter8.scala +++ b/app/src/main/scala/giter8.scala @@ -27,14 +27,14 @@ class Giter8 extends xsbti.AppMain { new Exit(Giter8.run(config.arguments)) /** Runner shared my main-class runner */ - def run(args: Array[String]): Int = { + def run(args: Array[String], baseDirectory: File): Int = { val helper = new JgitHelper(new Git(new JGitInteractor), G8TemplateRenderer) val result = (args.partition { s => G8.Param.pattern.matcher(s).matches } match { case (params, options) => parser.parse(options, Config("")).map { config => - helper.run(config, params, new File(".")) + helper.run(config, params, baseDirectory) }.getOrElse(Left("")) case _ => Left(parser.usage) }) @@ -48,6 +48,8 @@ class Giter8 extends xsbti.AppMain { }) } + def run(args: Array[String]):Int = run(args, new File(".")) + val parser = new scopt.OptionParser[Config]("giter8") { head("g8", giter8.BuildInfo.version) // cmd("search") action { (_, config) => From ebe5beb266f8041c1436867ab8db34d649036639 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Mon, 27 Mar 2017 19:26:16 +0200 Subject: [PATCH 2/2] Resolve File(".") to an absolute file upfront, to prevent issues. --- app/src/main/scala/giter8.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/scala/giter8.scala b/app/src/main/scala/giter8.scala index 09bcc527..757251b5 100644 --- a/app/src/main/scala/giter8.scala +++ b/app/src/main/scala/giter8.scala @@ -48,7 +48,7 @@ class Giter8 extends xsbti.AppMain { }) } - def run(args: Array[String]):Int = run(args, new File(".")) + def run(args: Array[String]):Int = run(args, (new File(".")).getAbsoluteFile) val parser = new scopt.OptionParser[Config]("giter8") { head("g8", giter8.BuildInfo.version)