norgbackup/norg/borg/execute.nim
2024-08-19 02:21:46 +01:00

28 lines
587 B
Nim

import strutils
import strformat
import osproc
import ../model/borg_type
proc genCommand*(cmd: string, repo: string, others: seq[string]): string =
let args = others.join(" ")
let cmd = fmt"{BORG_BIN} {cmd} {repo} {args}"
return cmd
proc run*(cmd: string): int =
echo fmt"Trying to run : {cmd}"
try:
let res = execCmd(cmd)
return res
except:
echo getCurrentExceptionMsg()
return 1
proc runDiscard*(cmd: string): int =
echo fmt"Trying to run : {cmd}"
try:
let res = execCmd(cmd)
return res
except:
echo getCurrentExceptionMsg()
return 1