Exemple #1
0
        private string GetProject(Command commandToExecute, List<string> parametersSelectedByUser)
        {
            string project = string.Empty;
            bool moreThanOneProject = false;
            foreach (string param in parametersSelectedByUser)
            {
                if (commandToExecute.Alias[param].Settings.TryGetValue("Project", out project))
                {
                    if (moreThanOneProject)
                    {
                        Console.Error.WriteLine("Error: There can only be one project execution per command.");
                        return string.Empty;
                    }
                    moreThanOneProject = true;
                }
            }

            if (string.IsNullOrEmpty(project))
            {
                project = commandToExecute.DefaultValues.Project;
            }

            return project;
        }
Exemple #2
0
        private string GetTool(Command commandToExecute, string os, string configPath, List<string> parametersSelectedByUser)
        {
            string toolname = commandToExecute.DefaultValues.ToolName;
            string project = GetProject(commandToExecute, parametersSelectedByUser);

            Tool toolProperties = null;

            if(Tools.TryGetValue(toolname, out toolProperties))
            {
                SettingParameters["toolName"] = toolname;
                string value = string.Empty;
                if (toolProperties.osSpecific[os].TryGetValue("path", out value) && !string.IsNullOrEmpty(value))
                {
                    return Path.GetFullPath(Path.Combine(configPath, value));
                }
                else if (toolProperties.osSpecific[os].TryGetValue("filesExtension", out value) && !string.IsNullOrEmpty(value))
                {
                    string extension = value;
                    return Path.GetFullPath(Path.Combine(configPath, string.Format("{0}.{1}", project, extension)));
                }
                else
                {
                    Console.Error.WriteLine("Error: The process {0} has empty values for path and filesExtension properties. It is mandatory that one of the two has a value.", toolname);
                    return string.Empty;
                }
            }

            Console.Error.WriteLine("Error: The process {0} is not specified in the Json file.", toolname);
            return string.Empty;
        }
Exemple #3
0
 private bool BuildDefaultValueSettingsForCommand(Command commandToExecute, Dictionary<string, string> commandValues)
 {
     foreach (KeyValuePair<string, string> optSetting in commandToExecute.DefaultValues.Settings)
     {
         string currentValue;
         if (commandValues.TryGetValue(optSetting.Key, out currentValue))
         {
             if (string.IsNullOrEmpty(currentValue))
             {
                 commandValues[optSetting.Key] = optSetting.Value;
             }
         }
         else
         {
             Console.Error.WriteLine("Error: The setting {0} is not specified in the Json file.", optSetting.Key);
             return false;
         }
     }
     return true;
 }
Exemple #4
0
 private bool BuildRequiredValueSettingsForCommand(Command commandToExecute, List<string> requiredSettings, Dictionary<string, string> commandValues)
 {
     foreach (string reqSetting in requiredSettings)
     {
         foreach (KeyValuePair<string, string> sett in commandToExecute.Alias[reqSetting].Settings)
         {
             string value = sett.Value;
             string currentValue;
             if (commandValues.TryGetValue(sett.Key, out currentValue))
             {
                 if (string.IsNullOrEmpty(currentValue) || currentValue.Equals("default"))
                 {
                     commandValues[sett.Key] = value;
                 }
                 else if (!value.Equals("default") && !value.Equals(currentValue))
                 {
                     Console.Error.WriteLine("Error: The value for setting {0} can't be overwriten.", sett.Key);
                     return false;
                 }
             }
             else if (!sett.Key.Equals("toolName"))
             {
                 Console.Error.WriteLine("Error: The setting {0} is not specified in the Json file.", sett.Key);
                 return false;
             }
         }
     }
     return true;
 }
Exemple #5
0
        private string GetProject(Command commandToExecute, List<string> parametersSelectedByUser)
        {
            string project = string.Empty;

            if (parametersSelectedByUser != null)
            {
                if (parametersSelectedByUser.Count(p => commandToExecute.Alias[p].Settings.TryGetValue("Project", out project)) > 1)
                {
                    Console.Error.WriteLine("Error: There can only be one project execution per command.");
                    return string.Empty;
                }
            }

            if (string.IsNullOrEmpty(project))
            {
                project = commandToExecute.DefaultValues.Project;
            }

            return project;
        }
Exemple #6
0
        private string GetTool(Command commandToExecute, string os, string configPath, List<string> parametersSelectedByUser)
        {
            string toolname = commandToExecute.DefaultValues.ToolName;
            
            string project = GetProject(commandToExecute, parametersSelectedByUser);

            if (Tools.ContainsKey(toolname))
            {
                SettingParameters["toolName"] = toolname;
                
                if (toolname.Equals("msbuild"))
                {
                    return Path.GetFullPath(Path.Combine(configPath, os.Equals("windows") ? Tools[toolname].Run["windows"] : Tools[toolname].Run["unix"]));
                }
                else if (toolname.Equals("terminal"))
                {
                    string extension = os.Equals("windows") ? Tools[toolname].Run["windows"] : Tools[toolname].Run["unix"];
                    return Path.GetFullPath(Path.Combine(configPath, string.Format("{0}.{1}", project, extension)));
                }
            }
            Console.Error.WriteLine("Error: The process {0} is not specified in the Json file.", toolname);
            return string.Empty;
        }