diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/xbackup/script.py | 40 |
2 files changed, 39 insertions, 3 deletions
@@ -9,6 +9,7 @@ This is a convenience wrapper around the Borg backup tool. (Last finished task first) +- [x] argument parsing - [x] implement Arch Linux Packaging - [x] setup project structure @@ -17,7 +18,6 @@ This is a convenience wrapper around the Borg backup tool. (Highest priority first) -- [ ] argument parsing - [ ] config parsing - [ ] manual backup functionality / MVP - [ ] XMPP notification via [xbot](https://gitea.xengineering.eu/xengineering/xbot) diff --git a/src/xbackup/script.py b/src/xbackup/script.py index 198b6b3..9424b83 100644 --- a/src/xbackup/script.py +++ b/src/xbackup/script.py @@ -6,10 +6,46 @@ import argparse +import time +import sys def run(): """runs xbackup script functionality""" - parser = argparse.ArgumentParser() - parser.parse_args() + args = parse_arguments() + + if args.command == "backup": + print("Performing dummy backup based on '{}'".format(args.config)) + time.sleep(1) + print("Done!") + else: + print("Unknown command '{}'".format(args.command)) + sys.exit(1) + +def parse_arguments(): + """handles argument parsing with the argparse module""" + + # parser creation + parser = argparse.ArgumentParser( + prog="xbackup", + description="xbackup CLI Script to make a File-based full System Backup", + epilog="Project page: https://gitea.xengineering.eu/xengineering/xbackup", + ) + + # positional arguments + parser.add_argument("command", type=str, + help="the action to be performed", + choices=["backup"], + ) + + # optional arguments + parser.add_argument("-c", "--config", type=str, + metavar="CONFIG", + help="path to the JSON configuration file", + default="/etc/xbackup/config.json", + ) + + # argument parsing + args = parser.parse_args() + return args |