Argparse for package & backup
parent
834e523ae1
commit
76ace3c9da
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue