added version output
This commit is contained in:
parent
c8933f9b09
commit
1f9c53b3f2
3 changed files with 28 additions and 21 deletions
|
@ -5,15 +5,15 @@ var norg_args*: NorgArgs = newNorgArgs()
|
|||
|
||||
proc parseArgs*() =
|
||||
var p = newParser:
|
||||
help("Norg\r\nA portable borg backup wrapper utility")
|
||||
help("Norg -- " & VERSION & "\r\nA portable borg backup wrapper utility.")
|
||||
option("-c", "--config", help="Config file to use.")
|
||||
option("-d", "--destination", help="Destination when extracting backup", required = false)
|
||||
option("-d", "--destination", help="Destination when extracting backup,", required = false)
|
||||
option("-r", "--repository", help="Define an explicit repository to work on by either label or path.", required = false)
|
||||
option("-a", "--archive", help="The archive or snapshot to operate on", required = false)
|
||||
flag("-s","--stats",help="Provides statistics at the end of a backup (Borg only)")
|
||||
option("-a", "--archive", help="The archive or snapshot to operate on.", required = false)
|
||||
flag("-s","--stats",help="Provides statistics at the end of a backup (Borg only).")
|
||||
arg("command", help="The command to run, defaults to 'create' which will perform a backup.", default=some("create"))
|
||||
arg("further_args", nargs = -1, help="Any further arguments to send onto borg or restic.")
|
||||
flag("-v","--version",help="Shows the current norg version")
|
||||
flag("-v","--version",help="Shows the current norg version.")
|
||||
try:
|
||||
var opts = p.parse(commandLineParams())
|
||||
norg_args.config_file = opts.config
|
||||
|
@ -23,9 +23,7 @@ proc parseArgs*() =
|
|||
norg_args.archive = opts.archive
|
||||
norg_args.stats = opts.stats
|
||||
norg_args.further_args = opts.further_args
|
||||
if opts.version:
|
||||
echo "Norg Version: ", VERSION
|
||||
quit(0)
|
||||
norg_args.show_version = opts.version
|
||||
except ShortCircuit as err:
|
||||
if err.flag == "argparse_help":
|
||||
echo err.help
|
||||
|
|
|
@ -3,6 +3,7 @@ export command_type
|
|||
|
||||
type
|
||||
NorgArgs* = object
|
||||
show_version*: bool
|
||||
config_file*: string
|
||||
extract_destination*: string
|
||||
command*: Command
|
||||
|
|
|
@ -5,10 +5,16 @@ import restic/restic
|
|||
import model/encryption_type
|
||||
import utils/actions
|
||||
|
||||
proc showVersion() =
|
||||
echo "Norg Version: ", VERSION
|
||||
quit(0)
|
||||
|
||||
proc start() =
|
||||
parseArgs()
|
||||
norg_config.args = norg_args
|
||||
if norg_args.config_file != "":
|
||||
if norg_args.show_version:
|
||||
showVersion()
|
||||
elif norg_args.config_file != "":
|
||||
norg_config = parseConfigFile(norg_args.config_file)
|
||||
if norg_config.source_directories.len > 0 and norg_config.repositories.len > 0:
|
||||
run_actions(norg_config.actions.before_everything)
|
||||
|
@ -22,6 +28,8 @@ proc start() =
|
|||
run_actions(norg_config.actions.after_actions)
|
||||
run_actions(norg_config.actions.after_everything)
|
||||
delEncryptionPassphraseInfo()
|
||||
else:
|
||||
echo "No Config File Provided"
|
||||
|
||||
when isMainModule:
|
||||
start()
|
||||
|
|
Loading…
Reference in a new issue