2023-05-19 17:47:49 +02:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using Tranga;
|
2023-05-18 15:49:08 +02:00
|
|
|
|
using Tranga.Connectors;
|
|
|
|
|
|
2023-05-18 18:55:11 +02:00
|
|
|
|
namespace Tranga_CLI;
|
|
|
|
|
|
2023-05-20 15:05:41 +02:00
|
|
|
|
/*
|
|
|
|
|
* This is written with pure hatred for readability.
|
|
|
|
|
* At some point do this properly.
|
|
|
|
|
* Read at own risk.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-05-18 18:55:11 +02:00
|
|
|
|
public static class Tranga_Cli
|
2023-05-18 15:49:08 +02:00
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2023-05-20 14:07:38 +02:00
|
|
|
|
TaskManager.SettingsData settings;
|
|
|
|
|
string settingsPath = Path.Join(Directory.GetCurrentDirectory(), "data.json");
|
2023-05-19 20:33:53 +02:00
|
|
|
|
if (File.Exists(settingsPath))
|
2023-05-20 15:05:41 +02:00
|
|
|
|
settings = TaskManager.LoadData(Directory.GetCurrentDirectory());
|
2023-05-20 14:07:38 +02:00
|
|
|
|
else
|
|
|
|
|
settings = new TaskManager.SettingsData(Directory.GetCurrentDirectory(), null, new HashSet<TrangaTask>());
|
|
|
|
|
|
2023-05-19 20:33:53 +02:00
|
|
|
|
|
2023-05-20 14:07:38 +02:00
|
|
|
|
Console.WriteLine($"Output folder path [{settings.downloadLocation}]:");
|
2023-05-19 20:33:53 +02:00
|
|
|
|
string? tmpPath = Console.ReadLine();
|
|
|
|
|
while(tmpPath is null)
|
|
|
|
|
tmpPath = Console.ReadLine();
|
|
|
|
|
if(tmpPath.Length > 0)
|
2023-05-20 14:07:38 +02:00
|
|
|
|
settings.downloadLocation = tmpPath;
|
2023-05-18 18:51:43 +02:00
|
|
|
|
|
2023-05-20 14:07:38 +02:00
|
|
|
|
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
|
|
|
|
string? tmpUrl = Console.ReadLine();
|
|
|
|
|
while (tmpUrl is null)
|
|
|
|
|
tmpUrl = Console.ReadLine();
|
|
|
|
|
if (tmpUrl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Username:");
|
|
|
|
|
string? tmpUser = Console.ReadLine();
|
|
|
|
|
while (tmpUser is null || tmpUser.Length < 1)
|
|
|
|
|
tmpUser = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Password:");
|
|
|
|
|
string tmpPass = string.Empty;
|
|
|
|
|
ConsoleKey key;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
var keyInfo = Console.ReadKey(intercept: true);
|
|
|
|
|
key = keyInfo.Key;
|
|
|
|
|
|
|
|
|
|
if (key == ConsoleKey.Backspace && tmpPass.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Console.Write("\b \b");
|
|
|
|
|
tmpPass = tmpPass[0..^1];
|
|
|
|
|
}
|
|
|
|
|
else if (!char.IsControl(keyInfo.KeyChar))
|
|
|
|
|
{
|
|
|
|
|
Console.Write("*");
|
|
|
|
|
tmpPass += keyInfo.KeyChar;
|
|
|
|
|
}
|
|
|
|
|
} while (key != ConsoleKey.Enter);
|
|
|
|
|
|
|
|
|
|
settings.komga = new Komga(tmpUrl, tmpUser, tmpPass);
|
|
|
|
|
}
|
2023-05-19 16:27:56 +02:00
|
|
|
|
|
2023-05-20 14:07:38 +02:00
|
|
|
|
TaskMode(settings);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 14:07:38 +02:00
|
|
|
|
private static void TaskMode(TaskManager.SettingsData settings)
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-20 15:58:35 +02:00
|
|
|
|
TaskManager taskManager = new (settings);
|
2023-05-20 16:12:15 +02:00
|
|
|
|
ConsoleKey selection = PrintMenu(taskManager, settings.downloadLocation);
|
|
|
|
|
while (selection != ConsoleKey.Q)
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-20 16:12:15 +02:00
|
|
|
|
switch (selection)
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.L:
|
2023-05-19 19:23:37 +02:00
|
|
|
|
PrintTasks(taskManager.GetAllTasks());
|
2023-05-19 16:27:56 +02:00
|
|
|
|
break;
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.C:
|
|
|
|
|
CreateTask(taskManager, settings);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
break;
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.D:
|
|
|
|
|
RemoveTask (taskManager);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
break;
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.E:
|
2023-05-19 23:01:04 +02:00
|
|
|
|
ExecuteTaskNow(taskManager);
|
2023-05-19 19:20:44 +02:00
|
|
|
|
break;
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.S:
|
|
|
|
|
SearchTasks(taskManager);
|
2023-05-20 00:30:24 +02:00
|
|
|
|
break;
|
2023-05-20 16:12:15 +02:00
|
|
|
|
case ConsoleKey.R:
|
|
|
|
|
PrintTasks(taskManager.GetAllTasks().Where(eTask => eTask.state == TrangaTask.ExecutionState.Running).ToArray());
|
2023-05-19 16:27:56 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-05-20 16:12:15 +02:00
|
|
|
|
Console.WriteLine("Press any key.");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
selection = PrintMenu(taskManager, settings.downloadLocation);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
2023-05-19 19:21:54 +02:00
|
|
|
|
|
2023-05-20 14:50:48 +02:00
|
|
|
|
if (taskManager.GetAllTasks().Any(task => task.state == TrangaTask.ExecutionState.Running))
|
2023-05-19 19:21:54 +02:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Force quit (Even with running tasks?) y/N");
|
|
|
|
|
selection = Console.ReadKey().Key;
|
2023-05-20 14:07:38 +02:00
|
|
|
|
while(selection != ConsoleKey.Y && selection != ConsoleKey.N)
|
|
|
|
|
selection = Console.ReadKey().Key;
|
2023-05-19 19:21:54 +02:00
|
|
|
|
taskManager.Shutdown(selection == ConsoleKey.Y);
|
|
|
|
|
}else
|
2023-05-20 01:06:12 +02:00
|
|
|
|
// ReSharper disable once RedundantArgumentDefaultValue Better readability
|
2023-05-19 19:21:54 +02:00
|
|
|
|
taskManager.Shutdown(false);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
private static ConsoleKey PrintMenu(TaskManager taskManager, string folderPath)
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-19 19:23:37 +02:00
|
|
|
|
int taskCount = taskManager.GetAllTasks().Length;
|
2023-05-20 14:50:48 +02:00
|
|
|
|
int taskRunningCount = taskManager.GetAllTasks().Count(task => task.state == TrangaTask.ExecutionState.Running);
|
|
|
|
|
int taskEnqueuedCount =
|
|
|
|
|
taskManager.GetAllTasks().Count(task => task.state == TrangaTask.ExecutionState.Enqueued);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 14:50:48 +02:00
|
|
|
|
Console.WriteLine($"Download Folder: {folderPath} Tasks (Running/Queue/Total): {taskRunningCount}/{taskEnqueuedCount}/{taskCount}");
|
2023-05-19 23:00:04 +02:00
|
|
|
|
Console.WriteLine("U: Update this Screen");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.WriteLine("L: List tasks");
|
|
|
|
|
Console.WriteLine("C: Create Task");
|
|
|
|
|
Console.WriteLine("D: Delete Task");
|
2023-05-19 19:20:44 +02:00
|
|
|
|
Console.WriteLine("E: Execute Task now");
|
2023-05-20 00:30:24 +02:00
|
|
|
|
Console.WriteLine("S: Search Task");
|
|
|
|
|
Console.WriteLine("R: Running Tasks");
|
2023-05-19 20:34:09 +02:00
|
|
|
|
Console.WriteLine("Q: Exit");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
ConsoleKey selection = Console.ReadKey().Key;
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
return selection;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 19:23:37 +02:00
|
|
|
|
private static void PrintTasks(TrangaTask[] tasks)
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-19 19:23:37 +02:00
|
|
|
|
int taskCount = tasks.Length;
|
2023-05-20 14:50:48 +02:00
|
|
|
|
int taskRunningCount = tasks.Count(task => task.state == TrangaTask.ExecutionState.Running);
|
|
|
|
|
int taskEnqueuedCount = tasks.Count(task => task.state == TrangaTask.ExecutionState.Enqueued);
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.Clear();
|
|
|
|
|
int tIndex = 0;
|
2023-05-20 14:50:48 +02:00
|
|
|
|
Console.WriteLine($"Tasks (Running/Queue/Total): {taskRunningCount}/{taskEnqueuedCount}/{taskCount}");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
foreach(TrangaTask trangaTask in tasks)
|
2023-05-20 01:06:12 +02:00
|
|
|
|
Console.WriteLine($"{tIndex++:000}: {trangaTask}");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
private static void CreateTask(TaskManager taskManager, TaskManager.SettingsData settings)
|
|
|
|
|
{
|
|
|
|
|
TrangaTask.Task? tmpTask = SelectTaskType();
|
|
|
|
|
if (tmpTask is null)
|
|
|
|
|
return;
|
|
|
|
|
TrangaTask.Task task = (TrangaTask.Task)tmpTask!;
|
|
|
|
|
|
|
|
|
|
Connector? connector = null;
|
|
|
|
|
if (task != TrangaTask.Task.UpdateKomgaLibrary)
|
|
|
|
|
{
|
|
|
|
|
connector = SelectConnector(settings.downloadLocation, taskManager.GetAvailableConnectors().Values.ToArray());
|
|
|
|
|
if (connector is null)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Publication? publication = null;
|
|
|
|
|
if (task != TrangaTask.Task.UpdatePublications && task != TrangaTask.Task.UpdateKomgaLibrary)
|
|
|
|
|
{
|
|
|
|
|
publication = SelectPublication(connector!);
|
|
|
|
|
if (publication is null)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeSpan reoccurrence = SelectReoccurrence();
|
|
|
|
|
TrangaTask newTask = taskManager.AddTask(task, connector?.name, publication, reoccurrence, "en");
|
|
|
|
|
Console.WriteLine(newTask);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 23:01:04 +02:00
|
|
|
|
private static void ExecuteTaskNow(TaskManager taskManager)
|
2023-05-19 19:23:12 +02:00
|
|
|
|
{
|
|
|
|
|
TrangaTask[] tasks = taskManager.GetAllTasks();
|
2023-05-19 20:34:34 +02:00
|
|
|
|
if (tasks.Length < 1)
|
|
|
|
|
{
|
|
|
|
|
Console.Clear();
|
|
|
|
|
Console.WriteLine("There are no available Tasks.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-19 19:23:12 +02:00
|
|
|
|
PrintTasks(tasks);
|
|
|
|
|
|
2023-05-20 15:58:35 +02:00
|
|
|
|
Console.WriteLine("Enter q to abort");
|
2023-05-19 23:00:04 +02:00
|
|
|
|
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):");
|
2023-05-19 19:23:12 +02:00
|
|
|
|
|
|
|
|
|
string? selectedTask = Console.ReadLine();
|
|
|
|
|
while(selectedTask is null || selectedTask.Length < 1)
|
|
|
|
|
selectedTask = Console.ReadLine();
|
|
|
|
|
|
2023-05-20 15:58:35 +02:00
|
|
|
|
if (selectedTask.Length == 1 && selectedTask.ToLower() == "q")
|
|
|
|
|
{
|
2023-05-20 16:13:19 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 15:58:35 +02:00
|
|
|
|
Console.WriteLine("aborted.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int selectedTaskIndex = Convert.ToInt32(selectedTask);
|
|
|
|
|
taskManager.ExecuteTaskNow(tasks[selectedTaskIndex]);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Exception: {e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 19:23:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 16:27:56 +02:00
|
|
|
|
private static void RemoveTask(TaskManager taskManager)
|
|
|
|
|
{
|
|
|
|
|
TrangaTask[] tasks = taskManager.GetAllTasks();
|
2023-05-19 20:34:34 +02:00
|
|
|
|
if (tasks.Length < 1)
|
|
|
|
|
{
|
|
|
|
|
Console.Clear();
|
|
|
|
|
Console.WriteLine("There are no available Tasks.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-19 19:23:37 +02:00
|
|
|
|
PrintTasks(tasks);
|
|
|
|
|
|
2023-05-20 15:58:35 +02:00
|
|
|
|
Console.WriteLine("Enter q to abort");
|
2023-05-19 23:00:04 +02:00
|
|
|
|
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
|
|
|
|
|
string? selectedTask = Console.ReadLine();
|
|
|
|
|
while(selectedTask is null || selectedTask.Length < 1)
|
|
|
|
|
selectedTask = Console.ReadLine();
|
|
|
|
|
|
2023-05-20 15:58:35 +02:00
|
|
|
|
if (selectedTask.Length == 1 && selectedTask.ToLower() == "q")
|
|
|
|
|
{
|
2023-05-20 16:13:19 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 15:58:35 +02:00
|
|
|
|
Console.WriteLine("aborted.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int selectedTaskIndex = Convert.ToInt32(selectedTask);
|
|
|
|
|
taskManager.RemoveTask(tasks[selectedTaskIndex].task, tasks[selectedTaskIndex].connectorName, tasks[selectedTaskIndex].publication);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Exception: {e.Message}");
|
|
|
|
|
}
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
private static TrangaTask.Task? SelectTaskType()
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
|
|
|
|
Console.Clear();
|
|
|
|
|
string[] taskNames = Enum.GetNames<TrangaTask.Task>();
|
|
|
|
|
|
|
|
|
|
int tIndex = 0;
|
|
|
|
|
Console.WriteLine("Available Tasks:");
|
|
|
|
|
foreach (string taskName in taskNames)
|
|
|
|
|
Console.WriteLine($"{tIndex++}: {taskName}");
|
2023-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Enter q to abort");
|
2023-05-19 23:00:04 +02:00
|
|
|
|
Console.WriteLine($"Select Task (0-{taskNames.Length - 1}):");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
|
|
|
|
|
string? selectedTask = Console.ReadLine();
|
|
|
|
|
while(selectedTask is null || selectedTask.Length < 1)
|
|
|
|
|
selectedTask = Console.ReadLine();
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
if (selectedTask.Length == 1 && selectedTask.ToLower() == "q")
|
|
|
|
|
{
|
2023-05-20 16:13:19 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 16:12:15 +02:00
|
|
|
|
Console.WriteLine("aborted.");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int selectedTaskIndex = Convert.ToInt32(selectedTask);
|
|
|
|
|
string selectedTaskName = taskNames[selectedTaskIndex];
|
|
|
|
|
return Enum.Parse<TrangaTask.Task>(selectedTaskName);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Exception: {e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2023-05-19 16:27:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 17:47:49 +02:00
|
|
|
|
private static TimeSpan SelectReoccurrence()
|
2023-05-19 16:27:56 +02:00
|
|
|
|
{
|
2023-05-19 17:47:49 +02:00
|
|
|
|
Console.WriteLine("Select reoccurrence Timer (Format hh:mm:ss):");
|
|
|
|
|
return TimeSpan.Parse(Console.ReadLine()!, new CultureInfo("en-US"));
|
2023-05-18 19:24:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
private static Connector? SelectConnector(string folderPath, Connector[] connectors)
|
2023-05-18 19:24:44 +02:00
|
|
|
|
{
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.Clear();
|
|
|
|
|
|
|
|
|
|
int cIndex = 0;
|
|
|
|
|
Console.WriteLine("Connectors:");
|
|
|
|
|
foreach (Connector connector in connectors)
|
|
|
|
|
Console.WriteLine($"{cIndex++}: {connector.name}");
|
2023-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Enter q to abort");
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.WriteLine($"Select Connector (0-{connectors.Length - 1}):");
|
2023-05-18 18:51:43 +02:00
|
|
|
|
|
|
|
|
|
string? selectedConnector = Console.ReadLine();
|
|
|
|
|
while(selectedConnector is null || selectedConnector.Length < 1)
|
|
|
|
|
selectedConnector = Console.ReadLine();
|
2023-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
|
|
if (selectedConnector.Length == 1 && selectedConnector.ToLower() == "q")
|
|
|
|
|
{
|
2023-05-20 16:13:19 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 16:12:15 +02:00
|
|
|
|
Console.WriteLine("aborted.");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-05-19 16:27:56 +02:00
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int selectedConnectorIndex = Convert.ToInt32(selectedConnector);
|
|
|
|
|
return connectors[selectedConnectorIndex];
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Exception: {e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2023-05-18 19:24:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
private static Publication? SelectPublication(Connector connector)
|
2023-05-18 19:24:44 +02:00
|
|
|
|
{
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.Clear();
|
|
|
|
|
Console.WriteLine($"Connector: {connector.name}");
|
|
|
|
|
Console.WriteLine("Publication search query (leave empty for all):");
|
|
|
|
|
string? query = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
Publication[] publications = connector.GetPublications(query ?? "");
|
2023-05-18 17:42:47 +02:00
|
|
|
|
|
|
|
|
|
int pIndex = 0;
|
2023-05-19 16:27:56 +02:00
|
|
|
|
Console.WriteLine("Publications:");
|
2023-05-18 17:42:47 +02:00
|
|
|
|
foreach(Publication publication in publications)
|
|
|
|
|
Console.WriteLine($"{pIndex++}: {publication.sortName}");
|
2023-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Enter q to abort");
|
2023-05-18 17:42:47 +02:00
|
|
|
|
Console.WriteLine($"Select publication to Download (0-{publications.Length - 1}):");
|
2023-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
|
|
string? selectedPublication = Console.ReadLine();
|
|
|
|
|
while(selectedPublication is null || selectedPublication.Length < 1)
|
|
|
|
|
selectedPublication = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
if (selectedPublication.Length == 1 && selectedPublication.ToLower() == "q")
|
|
|
|
|
{
|
2023-05-20 16:13:19 +02:00
|
|
|
|
Console.Clear();
|
2023-05-20 16:12:15 +02:00
|
|
|
|
Console.WriteLine("aborted.");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-05-18 17:42:47 +02:00
|
|
|
|
|
2023-05-20 16:12:15 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int selectedPublicationIndex = Convert.ToInt32(selectedPublication);
|
|
|
|
|
return publications[selectedPublicationIndex];
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Exception: {e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SearchTasks(TaskManager taskManager)
|
|
|
|
|
{
|
|
|
|
|
string? query = Console.ReadLine();
|
|
|
|
|
while (query is null || query.Length < 1)
|
|
|
|
|
query = Console.ReadLine();
|
|
|
|
|
PrintTasks(taskManager.GetAllTasks().Where(qTask =>
|
|
|
|
|
qTask.ToString().ToLower().Contains(query, StringComparison.OrdinalIgnoreCase)).ToArray());
|
2023-05-18 19:24:44 +02:00
|
|
|
|
}
|
2023-05-18 15:49:08 +02:00
|
|
|
|
}
|