Skip to content
This repository
Browse code

no-exec switch, for when you need it

  • Loading branch information...
commit 2a340c8696a04eb858f6f40da3109e98e9d6ea44 1 parent d187d43
Nathan Hamblen authored
4 src/main/scala/apply.scala
@@ -17,7 +17,7 @@ object Apply extends Launch {
17 17 }.format(script))!
18 18 }
19 19
20   - def config(user: String, repo: String, name: String, launch: Launchconfig) = {
  20 + def config(user: String, repo: String, name: String, launch: Launchconfig, shouldExec: Boolean) = {
21 21 val launchconfig = configdir(user / repo / name / "launchconfig")
22 22
23 23 val place = scriptFile(name)
@@ -32,7 +32,7 @@ object Apply extends Launch {
32 32 }
33 33 }.toLeft {
34 34 allCatch.opt {
35   - exec(place.toString)
  35 + if (shouldExec) exec(place.toString)
36 36 } // ignore result status; the app might not have `--version`
37 37 "Conscripted %s/%s to %s".format(user, repo, place)
38 38 }
18 src/main/scala/conscript.scala
@@ -12,7 +12,9 @@ object Conscript {
12 12 clean_boot: Boolean = false,
13 13 setup: Boolean = false,
14 14 usage: Boolean = false,
15   - entries: Seq[ConfigEntry] = Nil)
  15 + shouldExec: Boolean = true,
  16 + entries: Seq[ConfigEntry] = Nil
  17 + )
16 18
17 19 /** This is the entrypoint for the runnable jar, as well as
18 20 * the sbt `run` action when in the conscript project. */
@@ -47,6 +49,9 @@ object Conscript {
47 49 opt("version", "print current version", {
48 50 config = config.copy(usage = true)
49 51 })
  52 + opt("no-exec", "don't execute program after install", {
  53 + config = config.copy(shouldExec = false)
  54 + })
50 55 argOpt("[<user>/<project>[/<version>]]", "github project", { p =>
51 56 config = config.copy(project = p)
52 57 })
@@ -73,13 +78,15 @@ object Conscript {
73 78 display.info(msg)
74 79 configure("n8han",
75 80 "conscript",
76   - configoverrides = Seq(ConfigVersion(BuildInfo.version))).right.flatMap { msg =>
  81 + true,
  82 + configoverrides = Seq(ConfigVersion(BuildInfo.version))
  83 + ).right.flatMap { msg =>
77 84 display.info(msg)
78 85 examine("cs")
79 86 }
80 87 }
81   - case Config(GhProject(user, repo, version), branch, _, _, _, entries) =>
82   - configure(user, repo, branch, entries ++ (Option(version) map { v => ConfigVersion(v) }).toSeq)
  88 + case Config(GhProject(user, repo, version), branch, _, _, _, shouldExec, entries) =>
  89 + configure(user, repo, shouldExec, branch, entries ++ (Option(version) map { v => ConfigVersion(v) }).toSeq)
83 90 case _ => Left(parser.usage)
84 91 }.getOrElse { Left(parser.usage) }.fold( { err =>
85 92 display.error(err)
@@ -109,6 +116,7 @@ object Conscript {
109 116
110 117 def configure(user: String,
111 118 repo: String,
  119 + shouldExec: Boolean,
112 120 branch: String = "master",
113 121 configoverrides: Seq[ConfigEntry] = Nil) =
114 122 Github.lookup(user, repo, branch).map { result =>
@@ -117,7 +125,7 @@ object Conscript {
117 125 case (either, (name, launch)) =>
118 126 either.right.flatMap { cur =>
119 127 val modLaunch = (launch /: configoverrides) {_ update _}
120   - Apply.config(user, repo, name, modLaunch).right.map {
  128 + Apply.config(user, repo, name, modLaunch, shouldExec).right.map {
121 129 cur + "\n" + _
122 130 }
123 131 }

0 comments on commit 2a340c8

Please sign in to comment.
Something went wrong with that request. Please try again.