Command-line options parser.
Ejemplo n.º 1
0
        private static int CreateBuild(Options options)
        {
            var buildCreator = new ManualBuildCreator(options, new TfsManager());
            var returnStatus = buildCreator.CreateBuild();

            var writer = returnStatus.IsError ? Console.Error : Console.Out;
            writer.WriteLine(returnStatus.Message);

            return returnStatus.ExitCode;
        }
Ejemplo n.º 2
0
        private static int CreateBuildAsUser(Options options)
        {
            int exitCode;
            var userNameParts = options.UserName.Split('\\');
            using (Impersonation.LogonUser(userNameParts[0], userNameParts[1], options.Password, LogonType.NewCredentials))
            {
                exitCode = CreateBuild(options);
            }

            return exitCode;
        }
Ejemplo n.º 3
0
 private static bool GetIsValid(Options options)
 {
     return
         options.IsHelpRequest ||
         !string.IsNullOrEmpty(options.BuildDefinition) &&
         !string.IsNullOrEmpty(options.BuildLabel) &&
         !string.IsNullOrEmpty(options.DropLocation) &&
         !string.IsNullOrEmpty(options.ProjectName) &&
         !string.IsNullOrEmpty(options.TfsServerCollectionUrl) &&
         !((string.IsNullOrEmpty(options.UserName) && !string.IsNullOrEmpty(options.Password)) ||
           (!string.IsNullOrEmpty(options.UserName) && string.IsNullOrEmpty(options.Password)));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Factory method that creates an Options object.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        /// <returns>A configured Options object.</returns>
        public static Options GetOptions(string[] args)
        {
            var options = new Options();

            using (var parser = Parser.Default)
            {
                if (parser.ParseArguments(args, options))
                {
                    options.IsValid = GetIsValid(options);
                }
            }

            return options;
        }