public void Run() { FlagCollection parentFlags = FlagCollection.current; FlagCollection.current = flags; callingTask = currentTask; currentTask = this; Execute(); currentTask = callingTask; FlagCollection.current = parentFlags; }
public static Task Create(string[] args) { Task task = null; List <string> param = new List <string>(); List <object> flagNames = new List <object>(); foreach (string arg in args) { // Flag names if (arg.StartsWith("--")) { flagNames.Add(arg.Substring(2)); } // Flag codes else if (arg.StartsWith("-")) { foreach (char code in arg.Substring(1)) { flagNames.Add(code); } } // Task name else if (task == null && registeredTasks.ContainsKey(arg)) { task = registeredTasks[arg]; } // Task parameters else { param.Add(arg); } } if (task == null) { task = defaultTask; } FlagCollection flags = new FlagCollection(); task.DefaultFlags(flags); foreach (object flag in flagNames) { if (flag is char) { flags.Set((char)flag); } else { flags.Set((string)flag); } } task = task.NewTask(); task.flags = flags; task.arguments = param.ToArray(); return(task); }
public Task(string[] arguments, FlagCollection flags) { this.arguments = arguments; this.flags = flags; }
public abstract void DefaultFlags(FlagCollection flags);