void handleRmdepMethod(Item item, string[] args, ref int idx) { if (args.Length <= idx) { printNodepMethodErrorMessage(); return; } try { var id = UInt64.Parse(args[idx]); var item2 = ItemGroup.getItemById(id); var didRemove = ItemGroup.Items.removeDependency(item, item2); if (didRemove) { Console.WriteLine("Item #" + item.Id + " is no longer dependent on item #" + item2.Id + "."); } else { Console.WriteLine("Item #" + item.Id + " was not dependent on item #" + item2.Id + "."); } ItemGroupFile.save(); return; } catch { printNodepMethodErrorMessage(); return; } }
void handleDepMethod(Item item, string[] args, ref int idx) { if (args.Length <= idx) { printDepMethodErrorMessage(); return; } try { var id = UInt64.Parse(args[idx]); var item2 = ItemGroup.getItemById(id); addDependency(item, item2); ItemGroupFile.save(); return; } catch { printDepMethodErrorMessage(); return; } }
public void parseArgs(string[] args) { if (args.Length == 0) { handleEmptyArgs(); return; } int idx = 0; switch (args[0]) { case "prompt": case "p": { enterPromptLoop(); break; } case "help": { printHelp(); return; } case "next": { idx++; parseNextCommand(args, ref idx); return; } case "add": case "a": { idx++; parseAddCommand(args, ref idx); return; } case "chain": case "c": { idx++; parseChainCommand(args, ref idx); return; } case "group": case "g": { idx++; parseGroupCommand(args, ref idx); return; } case "remove": case "rm": { idx++; parseRemoveCommand(args, ref idx); return; } case "rename": case "rn": { idx++; parseRenameCommand(args, ref idx); return; } case "list": case "l": { idx++; parseListCommand(args, ref idx); return; } case "tree": case "t": { idx++; parseTreeCommand(args, ref idx); return; } case "skip": case "s": { idx++; handleSkipCommand(args, ref idx); return; } case "done": case "d": { idx++; handleDoneCommand(args, ref idx); return; } case "comment": { idx++; handleCommentCommand(args, ref idx); return; } default: { if (args[0].Length > 0) { // Queries if (args[0][0] == '?') { idx++; handleQuery(args[0], args, ref idx); return; } else { // Methods on Items var idStr = args[0]; try { UInt64 idNum = UInt64.Parse(idStr); var item = ItemGroup.getItemById(idNum); idx++; handleMethodOnItem(item, args, ref idx); return; } catch { Console.WriteLine("Expecting a keyword or an item id number. Found \"" + args[0] + "\" instead."); return; } } } return; } } }