Пример #1
0
        public RivetParameters Parse(IEnumerable<string> args)
        {
            var parameters = new RivetParameters();

            var targetDirectoryArgument = args.FirstOrDefault();
            if (string.IsNullOrEmpty(targetDirectoryArgument))
            {
                parameters.DisplayHelpInformation = true;
                return parameters;
            }

            // extract target directory
            var targetDirectoryMatch = TargetDirectoryScanExpression.Match(targetDirectoryArgument);
            if (targetDirectoryMatch.Success)
            {
                parameters.TargetDirectory = targetDirectoryMatch.Value.TrimEnd('\\');
            }
            else
            {
                // not an absolute path, treat as relative path
                parameters.TargetDirectory = Path.Combine(Environment.CurrentDirectory, targetDirectoryArgument.TrimEnd('\\'));
            }

            // extract variables
            foreach (var arg in args)
            {
                var matches = VariableScanExpression.Matches(arg);
                if (matches.Count == 1)
                {
                    parameters.AddVariable(matches[0].Groups["key"].Value, matches[0].Groups["value"].Value);
                }
            }

            return parameters;
        }
Пример #2
0
 private static void ExtractVariables(string arg, RivetParameters parameters)
 {
     foreach (var component in arg.Split(new[] {";"}, StringSplitOptions.RemoveEmptyEntries))
     {
         var matches = VariableScanExpression.Matches(component);
         if (matches.Count == 1)
         {
             parameters.AddVariable(matches[0].Groups["key"].Value, matches[0].Groups["value"].Value);
         }
     }
 }