Beispiel #1
0
        void enterPromptLoop()
        {
            string command;

            while (true)
            {
                Console.WriteLine();
                Console.Write(kPromptSymbol);
                command = Console.ReadLine();
                if (command == "quit" || command == "q")
                {
                    return;
                }

                //  Split the command up just like the shell would do and pass it to the argument parser
                string[] splitCommand = CommandLineStringSplitter.SplitCommandLine(command).ToArray();
                parseArgs(splitCommand);
            }
        }
Beispiel #2
0
        void handleItemTooComplicated(Item item)
        {
            Console.WriteLine("Let's break up this item into smaller peices.");
            Console.WriteLine("Enter an item number to make it a sub-item, use 'add' to create a new a sub-item, ? to search, or 'q' to quit.");

            bool didAddSubtask = false;

            Item item2 = null;

            while (true)
            {
                Console.Write(kMenuPromptSymbol);
                var input = Console.ReadLine();

                if (input == "q")
                {
                    if (didAddSubtask)
                    {
                        Console.WriteLine("Congrats!  You have subdivided your task.");
                    }
                    else
                    {
                        Console.WriteLine("Warning: you haven't subdivided your task.");
                    }

                    return;
                }

                //  See if it's an item number
                UInt32 item2Id;
                if (UInt32.TryParse(input, out item2Id))
                {
                    item2 = ItemGroup.Items.getItemById(item2Id);
                    if (item2 == null)
                    {
                        Console.WriteLine("There is no item with that number.");
                        continue;
                    }
                    else
                    {
                        ItemGroup.Items.addDependency(item, item2);
                        printAddDepMethodMessage(item, item2);
                        ItemGroupFile.save();
                        didAddSubtask = true;
                        continue;
                    }
                }

                //  Break into words and see if its add or ?
                var inputSplit = CommandLineStringSplitter.SplitCommandLine(input).ToArray <String>();
                if (inputSplit.Length == 0)
                {
                    continue;
                }

                if (inputSplit[0][0] == '?')
                {
                    int idx = 1;
                    handleQuery(inputSplit[0], inputSplit, ref idx);
                }
                else if (inputSplit[0] == "add")
                {
                    int idx = 1;
                    item2 = parseAddCommand(inputSplit, ref idx);
                    if (item2 == null)
                    {
                        continue;
                    }

                    ItemGroup.Items.addDependency(item, item2);
                    printAddDepMethodMessage(item, item2);
                    ItemGroupFile.save();
                    didAddSubtask = true;
                    continue;
                }
            }
        }
Beispiel #3
0
        void handleSomethingElseToBeDoneFirst(Item item)
        {
            Console.WriteLine("What needs to be done first?");
            Console.WriteLine("Enter an item number, an add command, ? to search, or 'q' to quit.");

            Item item2 = null;

            while (true)
            {
                Console.Write(kMenuPromptSymbol);
                var input = Console.ReadLine();

                if (input == "q")
                {
                    Console.WriteLine("That's what I thought.  Get back to work.");
                    return;
                }

                //  See if it's an item number
                UInt32 item2Id;
                if (UInt32.TryParse(input, out item2Id))
                {
                    item2 = ItemGroup.Items.getItemById(item2Id);
                    if (item2 == null)
                    {
                        Console.WriteLine("There is no item with that number.");
                        continue;
                    }
                    else
                    {
                        // generate the dependency when we exit the input loop.
                        break;
                    }
                }

                //  Break into words and see if its add or ?
                var inputSplit = CommandLineStringSplitter.SplitCommandLine(input).ToArray <String>();
                if (inputSplit.Length == 0)
                {
                    continue;
                }

                if (inputSplit[0][0] == '?')
                {
                    int idx = 1;
                    handleQuery(inputSplit[0], inputSplit, ref idx);
                }
                else if (inputSplit[0] == "add")
                {
                    int idx = 1;
                    item2 = parseAddCommand(inputSplit, ref idx);
                    if (item2 == null)
                    {
                        continue;
                    }

                    //  If they really created an item then assign it
                    //  to item2 and generate the dependency when we exit the input loop.
                    break;
                }
            }

            ItemGroup.Items.addDependency(item, item2);
            printAddDepMethodMessage(item, item2);
            ItemGroupFile.save();
        }