mirror of
https://github.com/daylinmorgan/forge.git
synced 2024-12-25 20:00:44 -06:00
fix: if args are given ignore config file for targets/bin
This commit is contained in:
parent
4485f832f0
commit
2009b16eb1
2 changed files with 24 additions and 18 deletions
|
@ -50,6 +50,7 @@ proc release(
|
|||
dryrun: bool = false,
|
||||
nimble: bool = false,
|
||||
configFile: string = ".forge.cfg",
|
||||
noConfig: bool = false,
|
||||
verbose: bool = false,
|
||||
) =
|
||||
## generate release assets for n>=1 targets
|
||||
|
@ -61,7 +62,7 @@ proc release(
|
|||
##
|
||||
## if name or version are not specified they will be inferred from the local .nimble file
|
||||
|
||||
var cfg = newConfig(
|
||||
let cfg = newConfig(
|
||||
target,
|
||||
bin,
|
||||
outdir,
|
||||
|
@ -69,8 +70,10 @@ proc release(
|
|||
name,
|
||||
version,
|
||||
nimble,
|
||||
configFile
|
||||
configFile,
|
||||
noConfig
|
||||
)
|
||||
|
||||
if cfg.targets.len == 0:
|
||||
termErrQuit "expected at least 1 target"
|
||||
if cfg.bins.len == 0:
|
||||
|
@ -114,7 +117,8 @@ proc release(
|
|||
termEcho styleBright, "cmd: ", ansiResetCode, cmd
|
||||
let errCode = execCmd cmd
|
||||
if errCode != 0:
|
||||
termErrQuit "problems executing cmd " & cmd
|
||||
termErr "cmd: ", cmd
|
||||
termErrQuit &"exited with code {errCode} see above for error"
|
||||
|
||||
when isMainModule:
|
||||
import cligen
|
||||
|
@ -148,7 +152,8 @@ when isMainModule:
|
|||
"dryrun": "show command instead of executing",
|
||||
"format": "set format, see help above",
|
||||
"nimble": "use nimble as base command for compiling",
|
||||
"config-file": "path to config"
|
||||
"config-file": "path to config",
|
||||
"no-config": "ignore config file"
|
||||
},
|
||||
short = {"verbose": 'V'}
|
||||
]
|
||||
|
|
|
@ -26,7 +26,7 @@ proc `$`*(c: Config): string =
|
|||
|
||||
lines.join("\n")
|
||||
|
||||
proc loadConfigFile*(f: string): Config =
|
||||
proc loadConfigFile*(f: string, load_targets: bool, load_bins: bool): Config =
|
||||
let
|
||||
dict = loadConfig(f)
|
||||
base = dict.getOrDefault("")
|
||||
|
@ -39,9 +39,9 @@ proc loadConfigFile*(f: string): Config =
|
|||
result.name = base.getOrDefault("name")
|
||||
result.version = base.getOrDefault("version")
|
||||
result.format = base.getOrDefault("format")
|
||||
if dict.hasKey("target"):
|
||||
if dict.hasKey("target") and load_targets:
|
||||
result.targets = dict.getOrDefault("target")
|
||||
if dict.hasKey("bin"):
|
||||
if dict.hasKey("bin") and load_bins:
|
||||
result.bins = dict.getOrDefault("bin")
|
||||
|
||||
proc inferName(s: string, nimbleFile: string): string =
|
||||
|
@ -85,20 +85,21 @@ proc inferBin(nimbleFile: string): string =
|
|||
|
||||
|
||||
proc newConfig*(
|
||||
targets: seq[string],
|
||||
bins: seq[string],
|
||||
outdir: string,
|
||||
format: string,
|
||||
name: string,
|
||||
version: string,
|
||||
nimble: bool,
|
||||
configFile: string
|
||||
): Config =
|
||||
targets: seq[string],
|
||||
bins: seq[string],
|
||||
outdir: string,
|
||||
format: string,
|
||||
name: string,
|
||||
version: string,
|
||||
nimble: bool,
|
||||
configFile: string,
|
||||
noConfig: bool
|
||||
): Config =
|
||||
|
||||
let nimbleFile = findNimbleFile()
|
||||
|
||||
if configFile.fileExists:
|
||||
result = loadConfigFile(configFile)
|
||||
if configFile.fileExists and not noConfig:
|
||||
result = loadConfigFile(configFile, targets.len == 0, bins.len == 0)
|
||||
else:
|
||||
# no seg faults here...
|
||||
result.targets = newOrderedTable[string, string]()
|
||||
|
|
Loading…
Reference in a new issue