示例#1
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;
            }

            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);
        }
示例#2
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;
            }

            if (r)
            {
                entry.Notes = "";
            }
            else
            {
                if (String.IsNullOrEmpty(note))
                {
                    Console.WriteLine("You need to supply a note.");
                    return;
                }

                if (!String.IsNullOrEmpty(entry.Notes))
                {
                    entry.Notes += "\n";
                }
                entry.Notes += note;
            }

            EntryList.SaveFile(file, list);
            Presentation.OutputEntryDetails(entry);
        }
示例#3
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;
                }

                if (pre == 0)
                {
                    Console.WriteLine("You need to specify the prereg.");
                    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.Preregs.RemoveAll(t => t == pre);
                }
                else if (!entry.Preregs.Any(t => t == pre))
                {
                    entry.Preregs.Add(pre);
                }

                EntryList.SaveFile(file, list);
                Presentation.OutputEntry(entry, null, 0);
            }
        }
示例#4
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);
        }
示例#5
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);

            var iter = all ? list.Root.EnumerateTree() : list.Root.EnumerateTree().Where(e => e.Status == "-" && e.ID != 0);

            var maxPriority  = iter.Max(e => e.Priority);
            var priorityList = iter.Where(e => e.Priority == maxPriority).ToList();
            var minID        = priorityList.Min(e => e.ID);
            var parentChain  = list.Root.FindParentChain(minID);

            Presentation.OutputChain(parentChain);

            // Todo: Skip when parent is complete / abandoned?
            // Todo: When a parent is high priority, and has incomplete children, display the child instead.
        }
示例#6
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);
            var statusHash = new Dictionary <String, int>();

            foreach (var task in list.Root.EnumerateTree())
            {
                if (statusHash.ContainsKey(task.Status))
                {
                    statusHash[task.Status] += 1;
                }
                else
                {
                    statusHash.Add(task.Status, 1);
                }
            }

            var total = statusHash.Values.Sum();

            Presentation.FillBar();
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            foreach (var tag in statusHash)
            {
                Presentation.FillLine();
                Console.WriteLine(String.Format("{0,5} {1} {2:00.00}%", tag.Value, tag.Key, ((float)tag.Value / (float)total * 100.0f)));
            }

            Presentation.FillLine();
            Console.WriteLine(String.Format("{0,5} Total Tasks", total));
            Presentation.FillBar();
            Console.ResetColor();
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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 (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);
            }
        }
示例#10
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);

            var entry = list.Root.FindChildWithID(id);

            if (entry == null)
            {
                Console.WriteLine("No entry with id {0} found.", id);
                return;
            }

            var matcher = (all || cdays > 0) ? (Matcher)(new MatchAllMatcher()) : new StatusMatcher {
                Status = "-"
            };

            if (!String.IsNullOrEmpty(search))
            {
                matcher = Presentation.ComposeMatchers(matcher, new RegexMatcher {
                    Pattern = new Regex(search)
                });
            }
            if (!String.IsNullOrEmpty(tag))
            {
                matcher = Presentation.ComposeMatchers(matcher, new TagMatcher {
                    Tag = tag
                });
            }
            if (p > 0)
            {
                matcher = Presentation.ComposeMatchers(matcher, new PriorityMatcher {
                    Priority = p
                });
            }
            if (days > 0)
            {
                matcher = Presentation.ComposeMatchers(matcher, new CreatedTimespanMatcher {
                    Days = days
                });
            }
            if (cdays > 0)
            {
                matcher = Presentation.ComposeMatchers(matcher, new CompletedTimespanMatcher {
                    Days = cdays
                });
            }

            var completeList = Presentation.SearchEntries(entry, matcher, 0).Where(l => (d == 0 || l.Depth <= d) && l.Depth >= 0).ToList();

            if (order == SortOrder.COMPLETION)
            {
                completeList.Sort((a, b) => (int)(a.Entry.CompletionTime - b.Entry.CompletionTime).TotalMilliseconds);
            }

            Presentation.DisplayPaginated(completeList);
        }