2024-08-16 17:40:24 +02:00
|
|
|
import ../model/config_type
|
2024-08-23 10:50:53 +02:00
|
|
|
import ../model/command_type
|
2024-08-18 19:45:37 +02:00
|
|
|
import ../utils/actions
|
2024-08-27 22:16:31 +02:00
|
|
|
import ../model/log_type
|
2024-08-16 17:40:24 +02:00
|
|
|
|
2024-08-19 03:21:46 +02:00
|
|
|
import execute
|
|
|
|
import prune
|
|
|
|
import create
|
|
|
|
import mount
|
|
|
|
import extract
|
2024-08-16 17:40:24 +02:00
|
|
|
|
|
|
|
|
2024-08-27 22:16:31 +02:00
|
|
|
|
2024-08-16 17:40:24 +02:00
|
|
|
proc initRepo(nc: NorgConfig, repo: Repository): int =
|
2024-08-23 13:04:27 +02:00
|
|
|
return runDiscard genCommand(cmd = "init", repo = repo.path, further_args = nc.args.further_args)
|
2024-08-16 17:40:24 +02:00
|
|
|
|
|
|
|
proc listArchives(nc: NorgConfig, repo: Repository): int =
|
2024-08-23 13:04:27 +02:00
|
|
|
return run genCommand(cmd = "list", repo = repo.path, further_args = nc.args.further_args)
|
2024-08-16 17:40:24 +02:00
|
|
|
|
2024-08-18 19:45:37 +02:00
|
|
|
proc compactRepo(nc: NorgConfig, repo: Repository): int =
|
2024-08-27 22:16:31 +02:00
|
|
|
error "Not Yet Implemented."
|
2024-08-18 19:45:37 +02:00
|
|
|
discard
|
|
|
|
|
|
|
|
proc checkRepo(nc: NorgConfig, repo: Repository): int =
|
2024-08-27 22:16:31 +02:00
|
|
|
error "Not Yet Implemented."
|
2024-08-18 19:45:37 +02:00
|
|
|
discard
|
|
|
|
|
2024-08-23 15:08:14 +02:00
|
|
|
proc execute*(nc: NorgConfig, repo: Repository): int {.discardable.} =
|
2024-08-23 10:50:53 +02:00
|
|
|
case nc.args.command
|
|
|
|
of INIT:
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Initializing repo: ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard initRepo(nc, repo)
|
|
|
|
of CREATE:
|
|
|
|
run_actions(norg_config.actions.before_backup)
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Creating archive on ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard createBackup(nc, repo)
|
|
|
|
run_actions(norg_config.actions.after_backup)
|
|
|
|
of LIST:
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Listing Archives on ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard listArchives(nc, repo)
|
|
|
|
of MOUNT:
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Mounting Archive from ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard mountArchive(nc, repo)
|
|
|
|
of UMOUNT:
|
|
|
|
discard unmountArchive(nc)
|
|
|
|
of EXTRACT:
|
|
|
|
run_actions(norg_config.actions.before_extract)
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Extracting archive from ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard extractArchive(nc, repo)
|
|
|
|
run_actions(norg_config.actions.after_extract)
|
|
|
|
of PRUNE:
|
|
|
|
run_actions(norg_config.actions.before_prune)
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Pruning repo: ", repo.label
|
2024-08-23 10:50:53 +02:00
|
|
|
discard pruneRepo(nc, repo)
|
|
|
|
run_actions(norg_config.actions.after_prune)
|
2024-08-23 15:08:14 +02:00
|
|
|
of DELETE:
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Deleting Archive ", nc.args.archive
|
2024-08-23 15:08:14 +02:00
|
|
|
discard deleteArchive(nc, repo)
|
2024-08-23 10:50:53 +02:00
|
|
|
of COMPACT:
|
|
|
|
run_actions(norg_config.actions.before_compact)
|
|
|
|
discard compactRepo(nc, repo)
|
|
|
|
run_actions(norg_config.actions.after_compact)
|
|
|
|
of CHECK:
|
|
|
|
run_actions(norg_config.actions.before_check)
|
|
|
|
discard checkRepo(nc, repo)
|
|
|
|
run_actions(norg_config.actions.after_check)
|
2024-11-25 12:15:15 +01:00
|
|
|
else:
|
|
|
|
discard
|