public static void Main(string[] args) { try { var commands = new string[] { "add", "done", "remove", "--help", "list", "filter", "change", "due", "tag", "untag", "delete", "filterTag", "folder", "filterFolder" }; var arguments = new ArgumentList(args, commands); var taskList = new TaskList(); var tagList = new TagList(); var tagFolder = new TagFolder(); var loader = new FileIO(); loader.LoadTasks(taskList); loader.LoadTags(ref tagList); loader.LoadFolder(ref tagFolder); var dictionary = new Dictionary<string, ICommand>(); dictionary.Add(commands[0], new AddCommand()); dictionary.Add(commands[1], new DoneCommand()); dictionary.Add(commands[2], new RemoveCommand()); dictionary.Add(commands[3], new HelpCommand()); dictionary.Add(commands[4], new ListCommand()); dictionary.Add(commands[5], new FilterCommand()); dictionary.Add(commands[6], new ChangeCommand()); dictionary.Add(commands[7], new DueCommand()); dictionary.Add(commands[8], new TagCommand()); dictionary.Add(commands[9], new UntagCommand()); dictionary.Add(commands[10], new DeleteCommand()); dictionary.Add(commands[11], new FilterTagCommand()); dictionary.Add(commands[12], new FolderCommand()); dictionary.Add(commands[13], new FilterFolderCommand()); var invoker = new Invoker(dictionary); ICommand command = invoker.GetCommand(arguments.GetCommand()); command.Execute(arguments, taskList, tagList, tagFolder); } catch (ArgumentException) { Console.WriteLine("Invalid Command"); } catch (IndexOutOfRangeException) { DisplayHelp(); } catch (FormatException) { Console.WriteLine("Invalid date entered"); } }
public TaskManagerRepository() { var loader = new FileIO(); loader.LoadTasks(Tasks); }