This commit is contained in:
Jonathan Bernard
2017-03-08 09:16:23 -06:00
parent 0e4f13de9a
commit cc28e7f4bf
8 changed files with 290 additions and 112 deletions

View File

@ -1,12 +1,18 @@
import docopt, logging, os, sequtils
import docopt, logging, os, sequtils, tempfile
import strawboss/private/util
import strawboss/configuration
import strawboss/core
import strawboss/server
import strawboss/supervisor
let SB_VER = "0.1.0"
proc logProcOutput*(outMsg, errMsg: TaintedString, cmd: string) =
let prefix = if cmd != nil: cmd else: ""
if outMsg != nil: info prefix & "(stdout): " & outMsg
if errMsg != nil: info prefix & "(stderr): " & errMsg
when isMainModule:
if logging.getHandlers().len == 0:
@ -22,19 +28,41 @@ when isMainModule:
let doc = """
Usage:
strawboss serve
strawboss run <project> <step> [-r <ref>]"""
strawboss supervisor [-i <in-file>] [-o <out-file>]
strawboss run <project> <step> [options]
Options
-f --force-rebuild Force a build step to re-run even we have cached
results from building that step before for this
version of the project.
-r --reference <ref> Build the project at this commit reference.
-w --workspace <workspace> Use the given directory as the build workspace.
"""
let args = docopt(doc, version = "strawboss v" & SB_VER)
if args["run"]:
let projName = $args["<project>"]
let stepName = $args["<step>"]
let buildRef = if args["-r"]: $args["<ref>"] else: nil
let req = RunRequest(
projectName: $args["<project>"],
stepName: $args["<step>"],
buildRef: if args["--rreference"]: $args["<ref>"] else: nil,
forceRebuild: args["--force-rebuild"],
workspaceDir: if args["--workspace"]: $args["<workspace>"] else: mkdtemp())
try: core.runStep(cfg, projName, stepName, buildRef)
try:
let summary = core.runStep(cfg, req, logProcOutput)
# TODO: inspect result
except:
fatal "strawboss: " & getCurrentExceptionMsg()
fatal "strawboss: " & getCurrentExceptionMsg() & "."
quit(QuitFailure)
info "strawboss: build passed"
elif
elif args["serve"]: server.start(cfg)