mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 09:38:51 +00:00
Restructure
This commit is contained in:
@@ -19,7 +19,7 @@ class AppState: ObservableObject {
|
||||
@Published var sortedApps: [AppInfo] = []
|
||||
@Published var selectedItems = Set<URL>()
|
||||
@Published var currentView = CurrentDetailsView.empty
|
||||
@Published var currentPage = CurrentPage.installed
|
||||
@Published var currentPage = CurrentPage.applications
|
||||
@Published var showAlert: Bool = false
|
||||
@Published var sidebar: Bool = true
|
||||
@Published var reload: Bool = false
|
||||
@@ -193,15 +193,17 @@ enum Arch {
|
||||
case empty
|
||||
}
|
||||
|
||||
enum CurrentPage:Int
|
||||
enum CurrentPage:Int, CaseIterable, Identifiable
|
||||
{
|
||||
case installed
|
||||
case uninstalled
|
||||
case applications
|
||||
case orphans
|
||||
|
||||
var id: Int { rawValue }
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .installed: return "Installed"
|
||||
case .uninstalled: return "Uninstalled"
|
||||
case .applications: return "Applications"
|
||||
case .orphans: return "Orphaned Files"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func reversePreloader(allApps: [AppInfo], appState: AppState, locations: Locatio
|
||||
@AppStorage("settings.interface.animationEnabled") var animationEnabled: Bool = true
|
||||
|
||||
updateOnMain {
|
||||
appState.leftoverProgress.0 = "Finding leftover files, please wait..."
|
||||
appState.leftoverProgress.0 = "Finding orphaned files, please wait..."
|
||||
}
|
||||
ReversePathsSearcher(appState: appState, locations: locations, fsm: fsm, sortedApps: allApps).reversePathsSearch {
|
||||
updateOnMain {
|
||||
|
||||
@@ -91,14 +91,14 @@ func processCLI(arguments: [String], appState: AppState, locations: Locations, f
|
||||
|
||||
}
|
||||
|
||||
// Private function to list leftover files for uninstall, using the provided path
|
||||
// Private function to list orphaned files for uninstall, using the provided path
|
||||
func listLeftoverFiles() {
|
||||
print("[BETA] Pearcleaner CLI | List Leftover Files:\n")
|
||||
print("[BETA] Pearcleaner CLI | List Orphaned Files:\n")
|
||||
|
||||
// Get installed apps for filtering
|
||||
let sortedApps = getSortedApps(paths: fsm.folderPaths)
|
||||
|
||||
// Find leftover files
|
||||
// Find orphaned files
|
||||
let foundPaths = ReversePathsSearcher(locations: locations, fsm: fsm, sortedApps: sortedApps)
|
||||
.reversePathsSearchCLI()
|
||||
|
||||
@@ -106,7 +106,7 @@ func processCLI(arguments: [String], appState: AppState, locations: Locations, f
|
||||
for path in foundPaths {
|
||||
print(path.path)
|
||||
}
|
||||
print("\nFound \(foundPaths.count) leftover files.\n")
|
||||
print("\nFound \(foundPaths.count) orphaned files.\n")
|
||||
}
|
||||
|
||||
// Private function to uninstall the application bundle at a given path
|
||||
@@ -163,23 +163,23 @@ func processCLI(arguments: [String], appState: AppState, locations: Locations, f
|
||||
}
|
||||
}
|
||||
|
||||
// Private function to remove the leftover files
|
||||
// Private function to remove the orphaned files
|
||||
func removeLeftoverFiles() {
|
||||
print("[BETA] Pearcleaner CLI | Remove Leftover Files:\n")
|
||||
print("[BETA] Pearcleaner CLI | Remove Orphaned Files:\n")
|
||||
|
||||
// Get installed apps for filtering
|
||||
let sortedApps = getSortedApps(paths: fsm.folderPaths)
|
||||
|
||||
// Find leftover files
|
||||
// Find orphaned files
|
||||
let foundPaths = ReversePathsSearcher(locations: locations, fsm: fsm, sortedApps: sortedApps)
|
||||
.reversePathsSearchCLI()
|
||||
|
||||
let success = moveFilesToTrashCLI(at: foundPaths)
|
||||
if success {
|
||||
print("Leftover files have been moved to the trash successfully.\n")
|
||||
print("Orphaned files have been moved to the trash successfully.\n")
|
||||
exit(0)
|
||||
} else {
|
||||
print("Failed to move leftover files to trash.\n")
|
||||
print("Failed to move orphaned files to trash.\n")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
@@ -197,8 +197,8 @@ func processCLI(arguments: [String], appState: AppState, locations: Locations, f
|
||||
exit(0)
|
||||
}
|
||||
|
||||
// Handle --listlf or -lf option with a path argument for listing leftover files
|
||||
if options.contains("--list-leftover") || options.contains("-lf") {
|
||||
// Handle --listlf or -lf option with a path argument for listing orphaned files
|
||||
if options.contains("--list-orphaned") || options.contains("-lo") {
|
||||
listLeftoverFiles()
|
||||
exit(0)
|
||||
}
|
||||
@@ -217,8 +217,8 @@ func processCLI(arguments: [String], appState: AppState, locations: Locations, f
|
||||
exit(0)
|
||||
}
|
||||
|
||||
// Handle --uninstall-lf or -ulf option with a path argument for listing leftover files
|
||||
if options.contains("--remove-leftover") || options.contains("-rl") {
|
||||
// Handle --uninstall-lf or -ulf option with a path argument for listing orphaned files
|
||||
if options.contains("--remove-orphaned") || options.contains("-ro") {
|
||||
removeLeftoverFiles()
|
||||
exit(0)
|
||||
}
|
||||
@@ -235,10 +235,10 @@ func displayHelp() {
|
||||
[BETA] Pearcleaner CLI | Usage:
|
||||
|
||||
--list <path>, -l <path> List application files available for uninstall at the specified path
|
||||
--list-leftover, -lf List leftover files available for removal
|
||||
--list-orphaned, -lo List orphaned files available for removal
|
||||
--uninstall <path>, -u <path> Uninstall only the application bundle at the specified path
|
||||
--uninstall-all <path>, -ua <path> Uninstall application bundle and ALL related files at the specified path
|
||||
--remove-leftover, -rl Remove ALL leftover files (To ignore files, add them to the exception list within Pearcleaner settings)
|
||||
--remove-orphaned, -ro Remove ALL orphaned files (To ignore files, add them to the exception list within Pearcleaner settings)
|
||||
--help, -h Show this help message
|
||||
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user