AddOptionalArgumentWithoutInput() public method

public AddOptionalArgumentWithoutInput ( string argName, string helpMsg, string>.Action handler ) : void
argName string
helpMsg string
handler string>.Action
return void
Esempio n. 1
0
 private void CreateCommandLineParser()
 {
     argsHandler = new CommandLineParser(this);
     // Required args
     argsHandler.AddRequiredArgumentWithInput("s", Resource.DeploymentWorker_SourceArgMsg, (worker, value) => { worker.source = new FileInfo(value).FullName; });
     argsHandler.AddRequiredArgumentWithInput("n", Resource.DeploymentWorker_TargetArgMsg, (worker, value) => { worker.targetName = value; });
     // Optional args
     argsHandler.AddOptionalArgumentWithInput("x", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_SdkArgMsg, defaultSdkVersion),
                                              (worker, value) => { worker.HandleSdkVersionFromCommandLine(value); });
     argsHandler.AddOptionalArgumentWithInput("t", Resource.DeploymentWorker_TempDirArgMsg, (worker, value) => { worker.outputFolder = value; });
     argsHandler.AddOptionalArgumentWithInput("f", Resource.DeploymentWorker_ConfigArgMsg,
                                              (worker, value) =>
     {
         if (!Enum.TryParse <DependencyConfiguration>(value, true, out worker.configuration))
         {
             throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                       Resource.DeploymentWorker_argumentHelper_0_is_not_a_supported_configuration, value));
         }
     });
     argsHandler.AddOptionalArgumentWithInput("a", Resource.DeploymentWorker_ArchArgMsg,
                                              (worker, value) =>
     {
         if (!Enum.TryParse <TargetPlatform>(value, true, out worker.targetType))
         {
             throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                       Resource.DeploymentWorker_argumentHelper_0_is_not_a_supported_target_architecture,
                                                       value));
         }
     });
     argsHandler.AddOptionalArgumentWithInput("w", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_TargetUserNameArgMsg, defaultTargetUserName),
                                              (worker, value) => { worker.credentials.UserName = value; });
     argsHandler.AddOptionalArgumentWithInput("p", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_TargetPasswordArgMsg, defaultTargetPassword),
                                              (worker, value) => { worker.credentials.Password = value; });
     argsHandler.AddOptionalArgumentWithInput("o", Resource.DeploymentWorker_SaveAppxArgMsg, (worker, value) => { worker.copyOutputToFolder = value; });
     argsHandler.AddOptionalArgumentWithInput("x", Resource.DeploymentWorker_MakeAppxArgMsg, (worker, value) => { worker.makeAppxPath = value; });
     argsHandler.AddOptionalArgumentWithInput("g", Resource.DeploymentWorker_SignToolArgMsg, (worker, value) => { worker.signToolPath = value; });
     argsHandler.AddOptionalArgumentWithInput("w", Resource.DeploymentWorker_PowershellArgMsg, (worker, value) => { worker.powershellPath = value; });
     argsHandler.AddOptionalArgumentWithoutInput("d", Resource.DeploymentWorker_KeepTempArgMsg, (worker, value) => { worker.keepTempFolder = true; });
     argsHandler.AddHelpArgument(new string[] { "h", "help", "?" }, Resource.DeploymentWorker_HelpArgMsg);
 }
Esempio n. 2
0
 private void CreateCommandLineParser()
 {
     argsHandler = new CommandLineParser(this);
     // Required args
     argsHandler.AddRequiredArgumentWithInput("s", Resource.DeploymentWorker_SourceArgMsg, (worker, value) => { worker.source = new FileInfo(value).FullName; });
     argsHandler.AddRequiredArgumentWithInput("n", Resource.DeploymentWorker_TargetArgMsg, (worker, value) => { worker.targetName = value; });
     // Optional args
     argsHandler.AddOptionalArgumentWithInput("x", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_SdkArgMsg, defaultSdkVersion),
         (worker, value) => { worker.HandleSdkVersionFromCommandLine(value); });
     argsHandler.AddOptionalArgumentWithInput("t", Resource.DeploymentWorker_TempDirArgMsg, (worker, value) => { worker.outputFolder = value; });
     argsHandler.AddOptionalArgumentWithInput("f", Resource.DeploymentWorker_ConfigArgMsg,
         (worker, value) =>
         {
             if (!Enum.TryParse<DependencyConfiguration>(value, true, out worker.configuration))
             {
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                     Resource.DeploymentWorker_argumentHelper_0_is_not_a_supported_configuration, value));
             }
         });
     argsHandler.AddOptionalArgumentWithInput("a", Resource.DeploymentWorker_ArchArgMsg,
         (worker, value) =>
         {
             if (!Enum.TryParse<TargetPlatform>(value, true, out worker.targetType))
             {
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                     Resource.DeploymentWorker_argumentHelper_0_is_not_a_supported_target_architecture,
                     value));
             }
         });
     argsHandler.AddOptionalArgumentWithInput("w", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_TargetUserNameArgMsg, defaultTargetUserName),
         (worker, value) => { worker.credentials.UserName = value; });
     argsHandler.AddOptionalArgumentWithInput("p", string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_TargetPasswordArgMsg, defaultTargetPassword),
         (worker, value) => { worker.credentials.Password = value; });
     argsHandler.AddOptionalArgumentWithInput("o", Resource.DeploymentWorker_SaveAppxArgMsg, (worker, value) => { worker.copyOutputToFolder = value; });
     argsHandler.AddOptionalArgumentWithInput("x", Resource.DeploymentWorker_MakeAppxArgMsg, (worker, value) => { worker.makeAppxPath = value; });
     argsHandler.AddOptionalArgumentWithInput("g", Resource.DeploymentWorker_SignToolArgMsg, (worker, value) => { worker.signToolPath = value; });
     argsHandler.AddOptionalArgumentWithInput("w", Resource.DeploymentWorker_PowershellArgMsg, (worker, value) => { worker.powershellPath = value; });
     argsHandler.AddOptionalArgumentWithoutInput("d", Resource.DeploymentWorker_KeepTempArgMsg, (worker, value) => { worker.keepTempFolder = true; });
     argsHandler.AddHelpArgument(new string[] { "h", "help", "?" }, Resource.DeploymentWorker_HelpArgMsg);
 }