norgbackup/norg/borg/mount.nim

20 lines
700 B
Nim
Raw Normal View History

2024-08-19 03:21:46 +02:00
import ../model/config_type
import execute
import strformat
proc mountArchive*(nc: NorgConfig, repo: Repository): int =
let archive = repo.path & "::" & nc.args.further_args[0]
let further_args = nc.args.further_args[1..^1]
let ok = runDiscard genCommand(cmd = "mount", repo = archive, further_args = further_args)
2024-08-19 03:21:46 +02:00
if ok == 0:
echo fmt"Mounted {archive} at {further_args[0]}"
2024-08-19 03:21:46 +02:00
else:
echo "Failed to mount ", archive
proc unmountArchive*(nc: NorgConfig): int =
let ok = runDiscard genCommand(cmd = "umount", repo = "", further_args = nc.args.further_args)
2024-08-19 03:21:46 +02:00
if ok == 0:
echo "Unmounted ", nc.args.further_args[0]
2024-08-19 03:21:46 +02:00
else:
echo "Failed to unmount ", nc.args.further_args[0]