Beispiel #1
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]);
        }
Beispiel #2
0
        private DroneFlags GetFlags(ParameterTokenSet tokens)
        {
            var configFilename = tokens.PopFlagValue("-f", DroneConfig.DroneFileName);

            if (Directory.Exists(configFilename))
            {
                this.log.Debug("config filename is a directory, setting config filename to dir + default name");
                configFilename = Path.Combine(configFilename, DroneConfig.DroneFileName);
            }

            var isDebugEnabled = tokens.PopFlag("-d");
            var isConsoleLogColorsEnabled = !tokens.PopFlag("-no-colors");
            var logLevel = DroneLogManager.GetLogLevelFromString(tokens.PopFlagValue("-l", "info"));

            var flags = new DroneFlags(
                configFilename,
                isDebugEnabled,
                isConsoleLogColorsEnabled,
                logLevel);

            return flags;
        }