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" )
|
||||||
|
@ -352,7 +365,7 @@ except PersoconfRootDoesNotExistError:
|
||||||
log.warning("'%s' does not exist" % str(args.rootdir))
|
log.warning("'%s' does not exist" % str(args.rootdir))
|
||||||
|
|
||||||
# Ask before creating the directory
|
# 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'?"
|
"'%s'?"
|
||||||
% str(args.rootdir) ) :
|
% str(args.rootdir) ) :
|
||||||
log.info("The persoconf directory was not created")
|
log.info("The persoconf directory was not created")
|
||||||
|
@ -376,9 +389,35 @@ except PersoconfRootDoesNotExistError:
|
||||||
# LIST COMMAND
|
# LIST COMMAND
|
||||||
########################################
|
########################################
|
||||||
if args.command == "list":
|
if args.command == "list":
|
||||||
log.info("Listing all apps")
|
|
||||||
for app in persoconf.list_apps(logger=log):
|
app_list = persoconf.list_apps(logger=log)
|
||||||
print(app)
|
|
||||||
|
# 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
|
# DELETE COMMAND
|
||||||
########################################
|
########################################
|
||||||
|
|
Loading…
Reference in New Issue