2
0

Compare commits

...

3 Commits

View File

@ -8,12 +8,18 @@ public static class Tranga_Cli
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Output folder path [standard D:]:"); string folderPath = Directory.GetCurrentDirectory();
string? folderPath = Console.ReadLine(); string settingsPath = Path.Join(Directory.GetCurrentDirectory(), "lastPath.setting");
while(folderPath is null ) if (File.Exists(settingsPath))
folderPath = Console.ReadLine(); folderPath = File.ReadAllText(settingsPath);
if (folderPath.Length < 1)
folderPath = "D:"; Console.WriteLine($"Output folder path [{folderPath}]:");
string? tmpPath = Console.ReadLine();
while(tmpPath is null)
tmpPath = Console.ReadLine();
if(tmpPath.Length > 0)
folderPath = tmpPath;
File.WriteAllText(settingsPath, folderPath);
Console.Write("Mode (D: Interactive only, T: TaskManager):"); Console.Write("Mode (D: Interactive only, T: TaskManager):");
ConsoleKeyInfo mode = Console.ReadKey(); ConsoleKeyInfo mode = Console.ReadKey();
@ -106,12 +112,11 @@ public static class Tranga_Cli
int taskRunningCount = taskManager.GetAllTasks().Count(task => task.isBeingExecuted); int taskRunningCount = taskManager.GetAllTasks().Count(task => task.isBeingExecuted);
Console.Clear(); Console.Clear();
Console.WriteLine($"Download Folder: {folderPath} Tasks (Running/Total): {taskRunningCount}/{taskCount}"); Console.WriteLine($"Download Folder: {folderPath} Tasks (Running/Total): {taskRunningCount}/{taskCount}");
Console.WriteLine("Select Option:");
Console.WriteLine("L: List tasks"); Console.WriteLine("L: List tasks");
Console.WriteLine("C: Create Task"); Console.WriteLine("C: Create Task");
Console.WriteLine("D: Delete Task"); Console.WriteLine("D: Delete Task");
Console.WriteLine("E: Execute Task now"); Console.WriteLine("E: Execute Task now");
Console.WriteLine("Q: Exit with saving"); Console.WriteLine("Q: Exit");
ConsoleKey selection = Console.ReadKey().Key; ConsoleKey selection = Console.ReadKey().Key;
Console.WriteLine(); Console.WriteLine();
return selection; return selection;
@ -131,9 +136,15 @@ public static class Tranga_Cli
private static void ExecuteTask(TaskManager taskManager) private static void ExecuteTask(TaskManager taskManager)
{ {
TrangaTask[] tasks = taskManager.GetAllTasks(); TrangaTask[] tasks = taskManager.GetAllTasks();
if (tasks.Length < 1)
{
Console.Clear();
Console.WriteLine("There are no available Tasks.");
return;
}
PrintTasks(tasks); PrintTasks(tasks);
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):"); Console.WriteLine($"Select Task (0-{tasks.Length}):");
string? selectedTask = Console.ReadLine(); string? selectedTask = Console.ReadLine();
while(selectedTask is null || selectedTask.Length < 1) while(selectedTask is null || selectedTask.Length < 1)
@ -146,9 +157,15 @@ public static class Tranga_Cli
private static void RemoveTask(TaskManager taskManager) private static void RemoveTask(TaskManager taskManager)
{ {
TrangaTask[] tasks = taskManager.GetAllTasks(); TrangaTask[] tasks = taskManager.GetAllTasks();
if (tasks.Length < 1)
{
Console.Clear();
Console.WriteLine("There are no available Tasks.");
return;
}
PrintTasks(tasks); PrintTasks(tasks);
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):"); Console.WriteLine($"Select Task (0-{tasks.Length}):");
string? selectedTask = Console.ReadLine(); string? selectedTask = Console.ReadLine();
while(selectedTask is null || selectedTask.Length < 1) while(selectedTask is null || selectedTask.Length < 1)
@ -167,7 +184,7 @@ public static class Tranga_Cli
Console.WriteLine("Available Tasks:"); Console.WriteLine("Available Tasks:");
foreach (string taskName in taskNames) foreach (string taskName in taskNames)
Console.WriteLine($"{tIndex++}: {taskName}"); Console.WriteLine($"{tIndex++}: {taskName}");
Console.WriteLine($"Select Task (0-{taskNames.Length - 1}):"); Console.WriteLine($"Select Task (0-{taskNames.Length}):");
string? selectedTask = Console.ReadLine(); string? selectedTask = Console.ReadLine();
while(selectedTask is null || selectedTask.Length < 1) while(selectedTask is null || selectedTask.Length < 1)