예제 #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 ExtractTargetDirectory(string targetDirectoryArgument, RivetParameters parameters)
 {
     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('\\'));
     }
 }
예제 #3
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
            ExtractTargetDirectory(targetDirectoryArgument, parameters);

            foreach (var arg in args)
                ExtractVariables(arg, parameters);

            return parameters;
        }
예제 #4
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);
         }
     }
 }