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