Add a command to remove a file or folder only from the list
This commit is contained in:
		@@ -22,6 +22,7 @@ public static class HelpCommand
 | 
				
			|||||||
        Console.WriteLine("  add <path to file or folder>       Add a file or folder to the list");
 | 
					        Console.WriteLine("  add <path to file or folder>       Add a file or folder to the list");
 | 
				
			||||||
        Console.WriteLine("  delete <file or folder ID>         Deletes a file or folder");
 | 
					        Console.WriteLine("  delete <file or folder ID>         Deletes a file or folder");
 | 
				
			||||||
        Console.WriteLine("  deleteall        Deletes all items in the list");
 | 
					        Console.WriteLine("  deleteall        Deletes all items in the list");
 | 
				
			||||||
 | 
					        Console.WriteLine("  rmflist          Remove an entry ONLY from the list");
 | 
				
			||||||
        Console.WriteLine("  list             Lists all items in the list");
 | 
					        Console.WriteLine("  list             Lists all items in the list");
 | 
				
			||||||
        Console.WriteLine("  help             Shows this help message");
 | 
					        Console.WriteLine("  help             Shows this help message");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										41
									
								
								Commands/RemoveFromListCommand.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Commands/RemoveFromListCommand.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					using TBDel.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace TBDel.Commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RemoveFromListCommand
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public static async Task DeleteEntryFromList(String[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        var dbService = new DbService();
 | 
				
			||||||
 | 
					        if (args.Length > 1 && uint.TryParse(args[1], out uint id))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Console.ForegroundColor = ConsoleColor.Yellow;
 | 
				
			||||||
 | 
					            Console.Write($"Are you sure you want to remove the entry with ID {id} ONLY from the list? (y/N) ");
 | 
				
			||||||
 | 
					            Console.ResetColor();
 | 
				
			||||||
 | 
					            var input = Console.ReadLine();
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					            if (input != "y")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Console.ForegroundColor = ConsoleColor.Red;
 | 
				
			||||||
 | 
					                Console.WriteLine("Operation cancelled.");
 | 
				
			||||||
 | 
					                Console.ResetColor();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (await dbService.RemoveFileEntryAsync(id) || await dbService.RemoveFolderEntryAsync(id))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Console.ForegroundColor = ConsoleColor.Green;
 | 
				
			||||||
 | 
					                Console.WriteLine("Entry removed from the list.");
 | 
				
			||||||
 | 
					                Console.ResetColor();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Console.ForegroundColor = ConsoleColor.Red;
 | 
				
			||||||
 | 
					                Console.WriteLine("Something went wrong while removing the entry from list.");
 | 
				
			||||||
 | 
					                Console.ResetColor();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -4,7 +4,6 @@ namespace TBDel
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    internal class Program
 | 
					    internal class Program
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // TODO: Add a command to remove a file or folder only from the list
 | 
					 | 
				
			||||||
        static async Task Main(string[] args)
 | 
					        static async Task Main(string[] args)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Show the help message if no arguments are provided
 | 
					            // Show the help message if no arguments are provided
 | 
				
			||||||
@@ -27,6 +26,9 @@ namespace TBDel
 | 
				
			|||||||
                case "deleteall":
 | 
					                case "deleteall":
 | 
				
			||||||
                    await DeleteAllCommand.DeleteAll();
 | 
					                    await DeleteAllCommand.DeleteAll();
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "rmflist":
 | 
				
			||||||
 | 
					                    await RemoveFromListCommand.DeleteEntryFromList(args);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
                case "list":
 | 
					                case "list":
 | 
				
			||||||
                    await ListCommand.List(args);
 | 
					                    await ListCommand.List(args);
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ Usage: tbdel <command> [arguments]
 | 
				
			|||||||
Available commands:
 | 
					Available commands:
 | 
				
			||||||
add <path to file or folder>       Add a file or folder to the list
 | 
					add <path to file or folder>       Add a file or folder to the list
 | 
				
			||||||
delete <file or folder ID>         Deletes a file or folder
 | 
					delete <file or folder ID>         Deletes a file or folder
 | 
				
			||||||
 | 
					rmflist          Remove an entry ONLY from the list
 | 
				
			||||||
deleteall        Deletes all items in the list
 | 
					deleteall        Deletes all items in the list
 | 
				
			||||||
list             Lists all items in the list
 | 
					list             Lists all items in the list
 | 
				
			||||||
help             Shows this help message
 | 
					help             Shows this help message
 | 
				
			||||||
@@ -37,6 +38,11 @@ help             Shows this help message
 | 
				
			|||||||
  tbdel list
 | 
					  tbdel list
 | 
				
			||||||
  ```
 | 
					  ```
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					* Remove an entry ONLY from the list: **(Assuming '12345' is the ID of the entry you want to remove from the list)**
 | 
				
			||||||
 | 
					  ```shell
 | 
				
			||||||
 | 
					  tbdel rmflist 12345
 | 
				
			||||||
 | 
					  ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Delete an entry (using its ID): **(Assuming '12345' is the ID of the entry you want to delete)**
 | 
					* Delete an entry (using its ID): **(Assuming '12345' is the ID of the entry you want to delete)**
 | 
				
			||||||
  ```shell
 | 
					  ```shell
 | 
				
			||||||
  tbdel delete 12345
 | 
					  tbdel delete 12345
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user