Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        private void SetPropertyCommand(ParameterTokenSet tokens, DroneFlags flags)
        {
            var config = this.droneService.LoadConfig(flags.ConfigFileName);

            if (tokens.Count == 0)
            {
                this.log.Error("no key provided, must provide a key and value");
                return;
            }

            var key = tokens.Pop();

            if (key == null)
            {
                this.log.Error("no key provided. please provide a key");
                return;
            }

            var type = tokens.PopFlagValue("-t", "auto");

            var val = tokens.Pop();

            if (val == null)
            {
                this.log.Error("no value provided. please provide a value");
                return;
            }

            config.Props[key.Value] = (JToken)this.GetTokenJsonValue(val, type);

            this.droneService.SaveConfig(config);

            this.log.Info("key: {0}", key.Value);
            this.log.Info("value: {0}", config.Props[key.Value]);
        }
Ejemplo n.º 3
0
        private string GetCommand(ParameterTokenSet tokens, string[] args)
        {
            if (tokens == null)
                throw new ArgumentNullException("tokens");

            var commandToken = tokens.Pop();
            var command = "help";

            if (commandToken != null && args != null && args.Length >= 1 && commandToken.Value == args[0])
                commandToken = tokens.Pop();

            if (commandToken != null)
                command = commandToken.Value;

            return command;
        }