本文整理汇总了C#中CommandLineParser.GetParameterValue方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.GetParameterValue方法的具体用法?C# CommandLineParser.GetParameterValue怎么用?C# CommandLineParser.GetParameterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.GetParameterValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasUseableCommandLine
/// <summary>
/// TRUE if we believe there is enough information in the command line to proceed with running the headless task
/// </summary>
/// <param name="commandLine"></param>
/// <returns></returns>
public static bool HasUseableCommandLine(CommandLineParser commandLine)
{
//If the command line does not contain a "-command" argument, then we know there's nothing we can do
if(string.IsNullOrWhiteSpace(commandLine.GetParameterValue(Parameter_Command)))
{
return false;
}
return true;
}
示例2: FromCommandLine
/// <summary>
/// Creates a TaskMaster from command line arguments
/// </summary>
/// <param name="parsedCommandLine"></param>
/// <returns></returns>
public static TaskMaster FromCommandLine(CommandLineParser commandLine)
{
//----------------------------------------------------------------------
//Add common options
//----------------------------------------------------------------------
var taskOptions = new TaskMasterOptions();
//Log file
helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveLogFile, commandLine, CommandLineParser.Parameter_LogFile);
//Error file
helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveErrorsFile, commandLine, CommandLineParser.Parameter_ErrorsFile);
//Manual steps file
helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveManualSteps, commandLine, CommandLineParser.Parameter_ManualStepsFile);
//Verbose logging
if(commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_LogVerbose, false))
{
taskOptions.AddOption(TaskMasterOptions.Option_LogVerbose);
}
//Background keep alive requests
if (commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_BackgroundKeepAlive, false))
{
taskOptions.AddOption(TaskMasterOptions.Option_BackgroundKeepAlive);
}
//----------------------------------------------------------------------------
//Which command are we dealing with?
//----------------------------------------------------------------------------
var commandType = commandLine.GetParameterValue(CommandLineParser.Parameter_Command);
if(commandType == CommandLineParser.ParameterValue_Command_Inventory)
{
return helper_CreateTaskMaster_SiteInventory(
commandLine.GetParameterValue(CommandLineParser.Parameter_InventoryOutputFile)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromSiteUrl)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserId)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserPassword)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSystemAdmin)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_GenerateInventoryTwb, false)
,taskOptions
);
}
else if (commandType == CommandLineParser.ParameterValue_Command_Export)
{
return helper_CreateTaskMaster_SiteExport(
commandLine.GetParameterValue(CommandLineParser.Parameter_ExportDirectory)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromSiteUrl)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserId)
,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserPassword)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSystemAdmin) || commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSiteAdmin)
,commandLine.GetParameterValue(CommandLineParser.Parameter_ExportSingleProject)
,commandLine.GetParameterValue(CommandLineParser.Parameter_ExportOnlyWithTag)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_RemoveTagAfterExport, false)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_GenerateInfoFilesForDownloads, false)
, taskOptions
);
}
else if (commandType == CommandLineParser.ParameterValue_Command_Import)
{
return helper_CreateTaskMaster_SiteImport(
commandLine.GetParameterValue(CommandLineParser.Parameter_ImportDirectory)
,commandLine.GetParameterValue(CommandLineParser.Parameter_ToSiteUrl)
,commandLine.GetParameterValue(CommandLineParser.Parameter_ToUserId)
,commandLine.GetParameterValue(CommandLineParser.Parameter_ToUserPassword)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ToSiteIsSystemAdmin) || commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ToSiteIsSiteAdmin)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_RemapDataserverReferences)
,commandLine.GetParameterValue(CommandLineParser.Parameter_DBCredentialsFile)
,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ImportAssignContentOwnership)
,taskOptions
);
}
AppDiagnostics.Assert(false, "Unknown command: " + commandType);
return null;
}
示例3: helper_AddValueIfExists
/// <summary>
/// Helper: Adds a command line parameter (if it exists) to the Options colleciton
/// </summary>
/// <param name="options"></param>
/// <param name="optionKey"></param>
/// <param name="commandLine"></param>
/// <param name="commandLineKey"></param>
private static void helper_AddValueIfExists(TaskMasterOptions options, string optionKey, CommandLineParser commandLine, string commandLineKey)
{
var commandlineValue = commandLine.GetParameterValue(commandLineKey);
if (!string.IsNullOrWhiteSpace(commandlineValue))
{
options.AddOption(optionKey, commandlineValue);
}
}