#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os.path # ----------------------------------------------------------------------------- def init(parser): parser.add_argument( "apps", type=str, nargs="*", default=[], help="The apps to list ; defaults to all " \ "apps" ) parser.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." ) # ----------------------------------------------------------------------------- def run(args, persoconf, logger): app_list = persoconf.list_apps(logger=logger) # If no app is given: list all apps if args.apps == []: logger.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: if os.path.isdir( os.path.join(persoconf.path, app, f) ): print("\t%s/" % f) else: 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: logger.warning("No such app: %s" % app) continue # Print the app name print(app) # Print the app files for f in app_list[app].files: if os.path.isdir(persoconf.path + "/" + app + "/" + f): print("\t%s/" % f) else: print("\t%s" % f)