List files with the 'list' command
parent
310535f2b3
commit
cef6150cbb
|
@ -222,6 +222,19 @@ parser_help = subparsers.add_parser( "help" ,
|
||||||
parser_list = subparsers.add_parser( "list" ,
|
parser_list = subparsers.add_parser( "list" ,
|
||||||
help="List backuped apps" )
|
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
|
# Package
|
||||||
parser_package = subparsers.add_parser( "package" ,
|
parser_package = subparsers.add_parser( "package" ,
|
||||||
help="Package a persoconf repository" )
|
help="Package a persoconf repository" )
|
||||||
|
@ -376,10 +389,36 @@ except PersoconfRootDoesNotExistError:
|
||||||
# LIST COMMAND
|
# LIST COMMAND
|
||||||
########################################
|
########################################
|
||||||
if args.command == "list":
|
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")
|
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(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
|
# DELETE COMMAND
|
||||||
########################################
|
########################################
|
||||||
if args.command == "delete":
|
if args.command == "delete":
|
||||||
|
|
Loading…
Reference in New Issue