Beispiel #1
0
        public void Run()
        {
            FlagCollection parentFlags = FlagCollection.current;

            FlagCollection.current = flags;
            callingTask            = currentTask;
            currentTask            = this;
            Execute();
            currentTask            = callingTask;
            FlagCollection.current = parentFlags;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public Task(string[] arguments, FlagCollection flags)
 {
     this.arguments = arguments;
     this.flags     = flags;
 }
Beispiel #4
0
 public abstract void DefaultFlags(FlagCollection flags);