all repos — pls @ 4b069128d910c3155f8d6cb454def7e8754726d2

A polite but determined task runner.

Reverted system tasks.
h3rald h3rald@h3rald.com
Mon, 04 Oct 2021 10:46:47 +0200
commit

4b069128d910c3155f8d6cb454def7e8754726d2

parent

bb4952530f0ee29b16f80be7f924481eb749cf24

1 files changed, 1 insertions(+), 12 deletions(-)

jump to
M src/plspkg/project.nimsrc/plspkg/project.nim

@@ -1,6 +1,5 @@

import os, - tables, json, logging, strutils,

@@ -16,15 +15,12 @@ targets*: JsonNode

type PlsError = ref object of ValueError -type SystemTask = proc (params: string): void const plsTpl* = "pls.json".slurp const systemHelp = "help.json".slurp let systemProps = @["$$os:$1" % hostOS, "$$cpu:$1" % hostCPU] let placeholder = peg"'{{' {[^}]+} '}}'" -var systemTasks = initTable[string, SystemTask]() -systemTasks["$setCurrentDir"] = proc (params: string) = setCurrentDir(params) proc newPlsProject*(dir: string): PlsProject = result.dir = dir

@@ -47,7 +43,6 @@ let cfg = prj.configFile.parseFile

prj.version = cfg["version"].getInt prj.tasks = cfg["tasks"] prj.targets = cfg["targets"] - # Set system properties proc help*(prj: var PlsProject): JsonNode = result = newJObject()

@@ -143,7 +138,6 @@ proc execute*(prj: var PlsProject, task, alias: string): int {.discardable.} =

prj.load if not prj.targets.hasKey alias: raise PlsError(msg: "Target definition '$1' not found. Nothing to do." % [alias]) - notice "$1: $2" % [task, alias] let target = prj.targets[alias] var keys = newSeq[string](0) for key, val in target.pairs:

@@ -154,12 +148,7 @@ if prj.lookupTask(task, keys, res):

cmd = res["cmd"].getStr.replace(placeholder) do (m: int, n: int, c: openArray[string]) -> string: return target[c[0]].getStr notice "Executing: $1" % cmd - if cmd[0] == '$': - let parts = cmd.split(" ") - if systemTasks.hasKey(parts[0]): - systemTasks[parts[0]](parts[1..parts.len-1].join(" ")) - else: - result = execShellCmd cmd + result = execShellCmd cmd else: debug "Task '$1' not available for target '$2'" % [task, alias] setCurrentDir(prj.dir)