List files with the 'list' command

master
Lertsenem 2015-09-16 19:31:18 +02:00
parent 310535f2b3
commit cef6150cbb
1 changed files with 43 additions and 4 deletions

View File

@ -222,6 +222,19 @@ parser_help = subparsers.add_parser( "help" ,
parser_list = subparsers.add_parser( "list" ,
help="List backuped apps" )
parser_list.add_argument( "apps" ,
type=str ,
nargs="*" ,
default=[] ,
help="The apps to list ; defaults to all " \
"apps" )
parser_list.add_argument( "--show-files", "-f" ,
action="store_true" ,
help="Show the files for each app ; it is " \
"automatically set if you specify the apps " \
"to list." )
# Package
parser_package = subparsers.add_parser( "package" ,
help="Package a persoconf repository" )
@ -376,10 +389,36 @@ except PersoconfRootDoesNotExistError:
# LIST COMMAND
########################################
if args.command == "list":
app_list = persoconf.list_apps(logger=log)
# If no app is given: list all apps
if args.apps == []:
log.info("Listing all apps")
for app in persoconf.list_apps(logger=log):
for app in app_list:
# Print the app name
print(app)
# Print the files too if asked so
if args.show_files:
for f in app_list[app].files:
print("\t%s" % f)
# Some apps were specified, so we list them with their files
else:
for app in args.apps:
if app not in app_list:
log.warning("No such app: %s" % app)
continue
# Print the app name
print(app)
# Print the app files
for f in app_list[app].files:
print("\t%s" % f)
# DELETE COMMAND
########################################
if args.command == "delete":