From 76ace3c9daa26263b009de885c68769976b0337c Mon Sep 17 00:00:00 2001 From: Lertsenem Date: Sat, 8 Aug 2015 16:41:08 +0200 Subject: [PATCH] Argparse for package & backup --- persoconf/main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 persoconf/main.py diff --git a/persoconf/main.py b/persoconf/main.py new file mode 100755 index 0000000..57d50b7 --- /dev/null +++ b/persoconf/main.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import argparse + +# Argument parsing using argparse +parser = argparse.ArgumentParser() +parser.add_argument( "--dir", type=str, help="The persoconf directory to use", default="~/.config/persoconf/" ) + +subparsers = parser.add_subparsers( dest="command", title="commands", description="Valid commands", help="sub-command help" ) + +# Help +parser_help = subparsers.add_parser("help", help="Getting some help") + +# Package +parser_package = subparsers.add_parser("package", help="Package a persoconf repository") +parser_package.add_argument( "apps", type=str, help="The apps to package. Use all to make a global package.", nargs="*", default=["all"] ) + +# Backup +parser_backup = subparsers.add_parser("backup", help="Backup an apps configuration in the persoconf directory with the configuration in use now") +parser_backup.add_argument( 'apps', help='The apps to backup', type=str, nargs="*", default=["all"]) + + +args = parser.parse_args() + +print(args) + +