Prettify code
parent
e36ee84d07
commit
06b5372219
|
@ -182,89 +182,92 @@ def copy_file_or_directory(logger, path_dst, path_src, overwrite=True):
|
|||
# Argument parsing using argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument( "--rootdir",
|
||||
type=str,
|
||||
default="~/.config/persoconf/",
|
||||
parser.add_argument( "--rootdir" ,
|
||||
type=str ,
|
||||
default="~/.config/persoconf/" ,
|
||||
help="The persoconf directory to use" )
|
||||
|
||||
parser.add_argument( "--metafile",
|
||||
type=str,
|
||||
default="META",
|
||||
parser.add_argument( "--metafile" ,
|
||||
type=str ,
|
||||
default="META" ,
|
||||
help="The name of the metadata files" )
|
||||
|
||||
parser.add_argument( "--verbose", "-v",
|
||||
action="store_true",
|
||||
parser.add_argument( "--verbose", "-v" ,
|
||||
action="store_true" ,
|
||||
help="Spout out more logs" )
|
||||
|
||||
|
||||
subparsers = parser.add_subparsers( dest="command", title="commands")
|
||||
subparsers = parser.add_subparsers( dest="command" ,
|
||||
title="commands" )
|
||||
|
||||
# Help
|
||||
parser_help = subparsers.add_parser("help", help="Print this help")
|
||||
parser_help = subparsers.add_parser( "help" ,
|
||||
help="Print this help" )
|
||||
|
||||
# List
|
||||
parser_list = subparsers.add_parser("list", help="List backuped apps")
|
||||
parser_list = subparsers.add_parser( "list" ,
|
||||
help="List backuped apps" )
|
||||
|
||||
# Package
|
||||
parser_package = subparsers.add_parser( "package",
|
||||
parser_package = subparsers.add_parser( "package" ,
|
||||
help="Package a persoconf repository" )
|
||||
|
||||
parser_package.add_argument( "apps",
|
||||
type=str,
|
||||
nargs="*",
|
||||
default=[],
|
||||
parser_package.add_argument( "apps" ,
|
||||
type=str ,
|
||||
nargs="*" ,
|
||||
default=[] ,
|
||||
help="The apps to package ; defaults to all " \
|
||||
"apps" )
|
||||
|
||||
parser_package.add_argument( "--pkgtype", "-t",
|
||||
type=str,
|
||||
nargs="?",
|
||||
default="tgz",
|
||||
choices = [ "tgz" ],
|
||||
parser_package.add_argument( "--pkgtype", "-t" ,
|
||||
type=str ,
|
||||
nargs="?" ,
|
||||
default="tgz" ,
|
||||
choices = [ "tgz" ] ,
|
||||
help="The type of package to use" )
|
||||
|
||||
parser_package.add_argument( "--pkgname", "-p",
|
||||
type=str,
|
||||
nargs="?",
|
||||
default="persoconf." + (time.strftime("%Y%m%d")),
|
||||
parser_package.add_argument( "--pkgname", "-p" ,
|
||||
type=str ,
|
||||
nargs="?" ,
|
||||
default="persoconf." + (time.strftime("%Y%m%d")) ,
|
||||
help="The name of the package to create" )
|
||||
|
||||
# Update
|
||||
parser_update = subparsers.add_parser( "update",
|
||||
parser_update = subparsers.add_parser( "update" ,
|
||||
help="Backup an app configuration in " \
|
||||
"the persoconf directory with " \
|
||||
"the configuration in use now" )
|
||||
|
||||
parser_update.add_argument( "app",
|
||||
type=str,
|
||||
nargs="?",
|
||||
parser_update.add_argument( "app" ,
|
||||
type=str ,
|
||||
nargs="?" ,
|
||||
help="The app to update" )
|
||||
|
||||
parser_update.add_argument( "files",
|
||||
type=str,
|
||||
nargs="*",
|
||||
default=[],
|
||||
parser_update.add_argument( "files" ,
|
||||
type=str ,
|
||||
nargs="*" ,
|
||||
default=[] ,
|
||||
help="The files to update ; default to all " \
|
||||
"added files" )
|
||||
|
||||
# Add
|
||||
parser_add = subparsers.add_parser( "add",
|
||||
parser_add = subparsers.add_parser( "add" ,
|
||||
help="Add an app to the persoconf " \
|
||||
"directory, or add a config file " \
|
||||
"to an existing app" )
|
||||
|
||||
parser_add.add_argument( "app",
|
||||
type=str,
|
||||
parser_add.add_argument( "app" ,
|
||||
type=str ,
|
||||
help="The app to add, or the app to add a conf " \
|
||||
"file to" )
|
||||
|
||||
parser_add.add_argument( "conf",
|
||||
nargs="?",
|
||||
type=str,
|
||||
parser_add.add_argument( "conf" ,
|
||||
nargs="?" ,
|
||||
type=str ,
|
||||
help="The conf file or directory to add to the app" )
|
||||
|
||||
parser_add.add_argument( "--confname",
|
||||
type=str,
|
||||
parser_add.add_argument( "--confname" ,
|
||||
type=str ,
|
||||
help="A special name to save the conf " \
|
||||
"file/directory in the persoconf directory" )
|
||||
|
||||
|
|
Loading…
Reference in New Issue