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