Argparse for package & backup

master
Lertsenem 2015-08-08 16:41:08 +02:00
parent 834e523ae1
commit 76ace3c9da
1 changed files with 27 additions and 0 deletions

27
persoconf/main.py Executable file
View File

@ -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)