Esempio n. 1
0
        public static void Set(DroneEnv env)
        {
            if(env == null)
                throw new ArgumentNullException("env");

            current = env;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DroneTaskContext" /> class.
        /// </summary>
        /// <param name="module">The module from where the task came from.</param>
        /// <param name="task">The task being executed.</param>
        /// <param name="env">The env.</param>
        /// <param name="log">The task log.</param>
        /// <param name="taskRunner">The run task function use to run other tasks.</param>
        /// <exception cref="System.ArgumentNullException">module
        /// or
        /// task
        /// or
        /// config
        /// or
        /// taskLog
        /// or
        /// runTask</exception>
        public DroneTaskContext(
			DroneModule module,
			DroneTask task, 
			DroneEnv env,
			Logger log, 
			DroneTaskRunner taskRunner)
        {
            if(module == null)
                throw new ArgumentNullException("module");

            if(task == null)
                throw new ArgumentNullException("task");

            if(env == null)
                throw new ArgumentNullException("env");

            if(log == null)
                throw new ArgumentNullException("log");

            if(taskRunner == null)
                throw new ArgumentNullException("taskRunner");

            this.Module = module;
            this.Task = task;
            this.Env = env;
            this.Log = log;
            this.taskRunner = taskRunner;
        }
Esempio n. 3
0
        private void ListCommand(ParameterTokenSet tokens, DroneFlags flags)
        {
            var config = this.droneService.LoadConfig(flags.ConfigFileName);
            var env = new DroneEnv(config, flags);

            // need to add pattern matching to the check
            var tasks = this.droneService.GetTasks(env).ToList();

            var searchPatternFlag = tokens.Pop();

            if(searchPatternFlag != null)
            {
                var searchPattern = searchPatternFlag.Value ?? string.Empty;
                tasks = tasks.Where(x => Regex.IsMatch(x.Name, searchPattern)).ToList();
            }

            var taskCounter = 0;

            foreach (var task in tasks)
            {
                this.log.Info("{0}─ {1}", this.GetTaskListPositionSymbol(taskCounter, tasks.Count - 1, false), task.Name);

                if (task.Dependencies.Count > 0)
                {
                    var depCounter = 0;

                    foreach (var dep in task.Dependencies)
                    {
                        this.log.Info("│  {0}─ {1}", this.GetTaskListPositionSymbol(depCounter, task.Dependencies.Count - 1, true), dep);
                        depCounter += 1;
                    }
                }

                taskCounter += 1;
            }
        }
Esempio n. 4
0
 private void RunCommand(ParameterTokenSet tokens, DroneFlags flags)
 {
     var config = this.droneService.LoadConfig(flags.ConfigFileName);
     var env = new DroneEnv(config, flags);
     var taskNames = tokens.Where(x => !x.Value.StartsWith("-")).Select(x => x.Value);
     this.droneService.RunTasks(env, taskNames);
 }
Esempio n. 5
0
 private void CompileCommand(ParameterTokenSet tokens, DroneFlags flags)
 {
     var config = this.droneService.LoadConfig(flags.ConfigFileName);
     var env = new DroneEnv(config, flags);
     this.droneService.CompileTasks(env, LogLevel.Info);
 }