2015-12-07 10:36:07 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os.path
|
|
|
|
|
2017-01-02 16:17:12 -05:00
|
|
|
# -----------------------------------------------------------------------------
|
2015-12-07 10:36:07 -05:00
|
|
|
def init(parser):
|
2017-01-02 16:17:12 -05:00
|
|
|
parser.add_argument( "apps",
|
|
|
|
type=str,
|
|
|
|
nargs="*",
|
|
|
|
default=[],
|
2015-12-07 10:36:07 -05:00
|
|
|
help="The apps to list ; defaults to all " \
|
|
|
|
"apps" )
|
|
|
|
|
2017-01-02 16:17:12 -05:00
|
|
|
parser.add_argument( "--show-files", "-f",
|
|
|
|
action="store_true",
|
2015-12-07 10:36:07 -05:00
|
|
|
help="Show the files for each app ; it is " \
|
|
|
|
"automatically set if you specify the " \
|
|
|
|
"apps to list." )
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-02 16:17:12 -05:00
|
|
|
# -----------------------------------------------------------------------------
|
2015-12-07 10:36:07 -05:00
|
|
|
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:
|
2015-12-07 12:24:29 -05:00
|
|
|
if os.path.isdir( os.path.join(persoconf.path, app, f) ):
|
2015-12-07 10:36:07 -05:00
|
|
|
print("\t%s/" % f)
|
|
|
|
else:
|
2015-12-07 12:24:29 -05:00
|
|
|
print("\t%s" % f)
|
2015-12-07 10:36:07 -05:00
|
|
|
|
|
|
|
# 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:
|
2015-12-07 12:24:29 -05:00
|
|
|
print("\t%s" % f)
|