diff --git a/persoconf/main.py b/persoconf/main.py index afd5953..aa0ecb4 100755 --- a/persoconf/main.py +++ b/persoconf/main.py @@ -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" ) @@ -352,7 +365,7 @@ except PersoconfRootDoesNotExistError: log.warning("'%s' does not exist" % str(args.rootdir)) # Ask before creating the directory - if not yes_no_question( "Do you want to create the persoconf directory " \ + if not yes_no_question( "Do you want to create the persoconf directory " \ "'%s'?" % str(args.rootdir) ) : log.info("The persoconf directory was not created") @@ -376,9 +389,35 @@ except PersoconfRootDoesNotExistError: # LIST COMMAND ######################################## if args.command == "list": - log.info("Listing all apps") - for app in persoconf.list_apps(logger=log): - print(app) + + 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 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 ########################################