2024-08-19 02:21:46 +01:00
|
|
|
import strutils
|
|
|
|
import strformat
|
|
|
|
|
2024-08-23 09:50:53 +01:00
|
|
|
import ../model/command_type
|
|
|
|
import ../utils/run
|
|
|
|
export run
|
2024-08-19 02:21:46 +01:00
|
|
|
|
2024-08-24 22:32:10 +01:00
|
|
|
|
2024-08-23 12:04:27 +01:00
|
|
|
proc genCommand*(cmd: string, repo: string, further_args: seq[string]): string =
|
|
|
|
let args = further_args.join(" ")
|
2024-08-19 02:21:46 +01:00
|
|
|
let cmd = fmt"{BORG_BIN} {cmd} {repo} {args}"
|
|
|
|
return cmd
|
|
|
|
|
2024-08-27 19:27:36 +01:00
|
|
|
proc genCreateCommand*(repo: string, sources: seq[string], stats: bool, further_args: seq[string]): string =
|
2024-08-23 15:46:35 +01:00
|
|
|
let args = further_args.join(" ")
|
|
|
|
var stats_flag = "--stats"
|
|
|
|
if not stats: stats_flag = ""
|
2024-08-27 19:27:36 +01:00
|
|
|
var source_dirs = ""
|
|
|
|
for source in sources:
|
2024-08-27 20:29:56 +01:00
|
|
|
source_dirs &= fmt""""{source}" """
|
2024-08-27 19:27:36 +01:00
|
|
|
let cmd = fmt"{BORG_BIN} create {stats_flag} {repo} {source_dirs} {args}"
|
2024-08-23 15:46:35 +01:00
|
|
|
return cmd
|
|
|
|
|
2024-08-27 19:27:36 +01:00
|
|
|
proc genDeleteCommand*(repo: string, archive: string, further_args: seq[string]): string =
|
2024-08-23 14:08:14 +01:00
|
|
|
let args = further_args.join(" ")
|
2024-08-27 19:27:36 +01:00
|
|
|
let cmd = fmt"{BORG_BIN} delete {repo} {archive} {args}"
|
2024-08-23 14:08:14 +01:00
|
|
|
return cmd
|
|
|
|
|