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