diff --git a/mackup/main.py b/mackup/main.py index 71d1f04c7..747842391 100644 --- a/mackup/main.py +++ b/mackup/main.py @@ -5,10 +5,10 @@ Usage: mackup list - mackup [options] backup - mackup [options] restore + mackup [options] backup [--] [ ...] + mackup [options] restore [--] [ ...] mackup show - mackup [options] uninstall + mackup [options] uninstall [--] [ ...] mackup (-h | --help) mackup --version @@ -87,8 +87,14 @@ def printAppHeader(app_name): # Check the env where the command is being run mckp.check_for_usable_backup_env() + applications = sorted(mckp.get_apps_to_backup()) + + # To allow for specific applications to be backed up, we replace the full list with only the valid ones from the command line + if args[""]: + applications = list(set(args[""]) & set(applications)) + # Backup each application - for app_name in sorted(mckp.get_apps_to_backup()): + for app_name in applications: app = ApplicationProfile(mckp, app_db.get_files(app_name), dry_run, verbose) printAppHeader(app_name) app.backup() @@ -115,7 +121,13 @@ def printAppHeader(app_name): # Mackup has already been done app_names.discard(MACKUP_APP_NAME) - for app_name in sorted(app_names): + app_names = sorted(app_names) + + # To allow for specific applications to be restored up, we replace the full list with only the valid ones from the command line + if args[""]: + app_names = list(set(args[""]) & set(app_names)) + + for app_name in app_names: app = ApplicationProfile(mckp, app_db.get_files(app_name), dry_run, verbose) printAppHeader(app_name) app.restore() @@ -138,7 +150,13 @@ def printAppHeader(app_name): app_names = mckp.get_apps_to_backup() app_names.discard(MACKUP_APP_NAME) - for app_name in sorted(app_names): + app_names = sorted(app_names) + + # To allow for specific applications to be uninstalled, we replace the full list with only the valid ones from the command line + if args[""]: + app_names = list(set(args[""]) & set(app_names)) + + for app_name in app_names: app = ApplicationProfile( mckp, app_db.get_files(app_name), dry_run, verbose ) @@ -179,8 +197,8 @@ def printAppHeader(app_name): elif args["show"]: mckp.check_for_usable_environment() - app_name = args[""] - + app_name = args[""][0] # Needed because args[""] is now a list + # Make sure the app exists if app_name not in app_db.get_app_names(): sys.exit("Unsupported application: {}".format(app_name))