public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (id == 0) { Console.WriteLine("You need to specify the entry you're editing."); return; } var list = EntryList.LoadFile(file, true); var entry = list.Root.FindChildWithID(id); if (entry == null) { Console.WriteLine("Could not find entry with ID {0}.", id); return; } entry.Status = "-"; EntryList.SaveFile(file, list); Presentation.OutputEntry(entry, null, 0); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (id == 0) { Console.WriteLine("You need to specify the entry you're editing."); return; } var list = EntryList.LoadFile(file, true); var toDelete = list.Root.EnumerateParentChildPairs().FirstOrDefault(e => e.Child.ID == id); if (toDelete.Parent == null || toDelete.Child == null) { Console.WriteLine("No entry with id {0} found.", id); return; } if (toDelete.Child.Children.Count > 0 && !r) { Console.WriteLine("Entry {0} has children. To delete anyway, pass -r", id); return; } toDelete.Parent.Children.Remove(toDelete.Child); EntryList.SaveFile(file, list); Console.WriteLine("Deleted {0:X4}.", id); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (id == 0) { Console.WriteLine("You need to specify the entry you're editing."); return; } if (id == parent) { Console.WriteLine("Not going to work."); return; } var list = EntryList.LoadFile(file, true); var entry = list.Root.EnumerateParentChildPairs().FirstOrDefault(e => e.Child.ID == id); if (entry.Parent == null || entry.Child == null) { Console.WriteLine("Could not find entry with ID{0}.", id); return; } var newParent = list.Root.FindChildWithID(parent); if (newParent == null) { Console.WriteLine("Could not find entry with ID{0}.", id); return; } if (entry.Child.FindChildWithID(parent) != null) { Console.WriteLine("That would create a circular reference."); return; } entry.Parent.Children.Remove(entry.Child); newParent.Children.Add(entry.Child); EntryList.SaveFile(file, list); Presentation.OutputEntry(newParent, new StatusMatcher { Status = "-" }, 0); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (String.IsNullOrEmpty(desc)) { throw new InvalidOperationException("You need to specify what you're adding dumbass."); } var list = EntryList.LoadFile(file, true); var parent = list.Root.FindChildWithID(sub); if (parent == null) { Console.WriteLine("No entry with id {0} found.", sub); return; } var entry = new Entry { ID = list.NextID, Status = "-", Priority = 0, Description = desc }; parent.Children.Add(entry); PipedArguments["id"] = entry.ID; list.NextID += 1; EntryList.SaveFile(file, list); Presentation.OutputEntry(entry, null, 0); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (id == 0) { Console.WriteLine("You need to specify the entry you're editing."); return; } var list = EntryList.LoadFile(file, true); var entry = list.Root.FindChildWithID(id); if (entry == null) { Console.WriteLine("Could not find entry with ID{0}.", id); return; } foreach (var pre in entry.Preregs) { var check = list.Root.FindChildWithID(pre); if (check != null && check.Status != "✓") { Console.WriteLine("Could not mark this item complete as prereg {0:X4} is not complete.", pre); return; } } entry.Status = "✓"; entry.CompletionTime = DateTime.Now; EntryList.SaveFile(file, list); Presentation.OutputEntry(entry, null, 0); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } var list = EntryList.LoadFile(file, false); if (list.PreviousVersions.Count > 0) { list.Root = list.PreviousVersions[list.PreviousVersions.Count - 1]; list.PreviousVersions.RemoveAt(list.PreviousVersions.Count - 1); } else { Console.WriteLine("Nothing left to undo."); } EntryList.SaveFile(file, list); }
public void Invoke(Dictionary <String, Object> PipedArguments) { if (String.IsNullOrEmpty(file)) { Console.WriteLine("No file specified. How did you manage that? It defaults to todo.txt"); return; } if (l) { var list = EntryList.LoadFile(file, false); var tagHash = new Dictionary <String, int>(); foreach (var task in list.Root.EnumerateTree()) { foreach (var tag in task.Tags) { if (tagHash.ContainsKey(tag)) { tagHash[tag] += 1; } else { tagHash.Add(tag, 1); } } } Presentation.FillBar(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.DarkGreen; foreach (var tag in tagHash) { Presentation.FillLine(); Console.WriteLine(String.Format("{0,5} {1}", tag.Value, tag.Key)); } Presentation.FillBar(); Console.ResetColor(); } else { if (id == 0) { Console.WriteLine("You need to specify the entry you're editing."); return; } if (String.IsNullOrEmpty(tag)) { Console.WriteLine("You need to specify what tag you are adding or removing."); return; } var list = EntryList.LoadFile(file, true); var entry = list.Root.FindChildWithID(id); if (entry == null) { Console.WriteLine("Could not find entry with ID{0}.", id); return; } if (r) { entry.Tags.RemoveAll(t => t == tag); } else if (!entry.Tags.Any(t => t == tag)) { entry.Tags.Add(tag); } EntryList.SaveFile(file, list); Presentation.OutputEntry(entry, null, 0); } }