Skip to content

Commit

Permalink
no-exec switch, for when you need it
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hamblen committed Apr 12, 2012
1 parent d187d43 commit 2a340c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/apply.scala
Expand Up @@ -17,7 +17,7 @@ object Apply extends Launch {
}.format(script))!
}

def config(user: String, repo: String, name: String, launch: Launchconfig) = {
def config(user: String, repo: String, name: String, launch: Launchconfig, shouldExec: Boolean) = {
val launchconfig = configdir(user / repo / name / "launchconfig")

val place = scriptFile(name)
Expand All @@ -32,7 +32,7 @@ object Apply extends Launch {
}
}.toLeft {
allCatch.opt {
exec(place.toString)
if (shouldExec) exec(place.toString)
} // ignore result status; the app might not have `--version`
"Conscripted %s/%s to %s".format(user, repo, place)
}
Expand Down
18 changes: 13 additions & 5 deletions src/main/scala/conscript.scala
Expand Up @@ -12,7 +12,9 @@ object Conscript {
clean_boot: Boolean = false,
setup: Boolean = false,
usage: Boolean = false,
entries: Seq[ConfigEntry] = Nil)
shouldExec: Boolean = true,
entries: Seq[ConfigEntry] = Nil
)

/** This is the entrypoint for the runnable jar, as well as
* the sbt `run` action when in the conscript project. */
Expand Down Expand Up @@ -47,6 +49,9 @@ object Conscript {
opt("version", "print current version", {
config = config.copy(usage = true)
})
opt("no-exec", "don't execute program after install", {
config = config.copy(shouldExec = false)
})
argOpt("[<user>/<project>[/<version>]]", "github project", { p =>
config = config.copy(project = p)
})
Expand All @@ -73,13 +78,15 @@ object Conscript {
display.info(msg)
configure("n8han",
"conscript",
configoverrides = Seq(ConfigVersion(BuildInfo.version))).right.flatMap { msg =>
true,
configoverrides = Seq(ConfigVersion(BuildInfo.version))
).right.flatMap { msg =>
display.info(msg)
examine("cs")
}
}
case Config(GhProject(user, repo, version), branch, _, _, _, entries) =>
configure(user, repo, branch, entries ++ (Option(version) map { v => ConfigVersion(v) }).toSeq)
case Config(GhProject(user, repo, version), branch, _, _, _, shouldExec, entries) =>
configure(user, repo, shouldExec, branch, entries ++ (Option(version) map { v => ConfigVersion(v) }).toSeq)
case _ => Left(parser.usage)
}.getOrElse { Left(parser.usage) }.fold( { err =>
display.error(err)
Expand Down Expand Up @@ -109,6 +116,7 @@ object Conscript {

def configure(user: String,
repo: String,
shouldExec: Boolean,
branch: String = "master",
configoverrides: Seq[ConfigEntry] = Nil) =
Github.lookup(user, repo, branch).map { result =>
Expand All @@ -117,7 +125,7 @@ object Conscript {
case (either, (name, launch)) =>
either.right.flatMap { cur =>
val modLaunch = (launch /: configoverrides) {_ update _}
Apply.config(user, repo, name, modLaunch).right.map {
Apply.config(user, repo, name, modLaunch, shouldExec).right.map {
cur + "\n" + _
}
}
Expand Down

0 comments on commit 2a340c8

Please sign in to comment.