public CommandLineParser(IFluentCommandLineParser parser) { if (parser == null) throw new ArgumentNullException(nameof(parser)); _parser = parser; }
static void CallParserWithAllKeyVariations(IFluentCommandLineParser parser, string key, string value, Action <string[], ICommandLineParserResult> assertCallback) { foreach (string[] args in CreateAllKeyVariations(key, value)) { assertCallback(args, parser.Parse(args)); } }
public OctopusDeploymentProvider( IConfigurationSettings settings, ILogger logger, IBuildMatcher buildMatcher, IFluentCommandLineParser parser, IUsernameTransformer usernameTransformer) : base(logger, settings) { _buildMatcher = buildMatcher; _usernameTransformer = usernameTransformer; SetupOption(parser, "octopusUrl", "The server URL of the Octopus Deploy server to use.", "Octopus.ServerUrl", data => _serverAddress = data); SetupOption(parser, "octopusApiKey", "The API Key of the Octopus Deploy server to use.", "Octopus.ApiKey", data => _apiKey = data); SetupOption(parser, "octopusEnv", "The Octopus envrionment to validate, defaults to Prod", "Octopus.ProdEnvName", data => _environmentName = data); }
/// <summary> /// Initialises a new instance of the <see cref="CommandLineOptionValidator"/> class. /// </summary> public CommandLineOptionValidator(IFluentCommandLineParser parser) { _rules = new List<ICommandLineOptionValidator> { new OptionNameValidator(), new NoDuplicateOptionValidator(parser) }; }
/// <summary> /// Initialises a new instance of the <see cref="CommandLineOptionValidator"/> class. /// </summary> public CommandLineOptionValidator(IFluentCommandLineParser parser) { _rules = new List <ICommandLineOptionValidator> { new OptionNameValidator(), new NoDuplicateOptionValidator(parser) }; }
/// <summary> /// Initialises a new instance of the <see cref="NoDuplicateOptionValidator"/> class. /// </summary> /// <param name="parser">The <see cref="IFluentCommandLineParser"/> containing the setup options. This must not be null.</param> public NoDuplicateOptionValidator(IFluentCommandLineParser parser) { if (parser == null) { throw new ArgumentNullException("parser"); } _parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="CommandLineOptionBuilderFluent{TBuildType, TProperty}" /> class. /// </summary> /// <param name="parser">The parser.</param> /// <param name="buildObject">The build object.</param> /// <param name="propertyPicker">The property picker.</param> public CommandLineOptionBuilderFluent( IFluentCommandLineParser parser, TBuildType buildObject, Expression <Func <TBuildType, TProperty> > propertyPicker) { _parser = parser; _buildObject = buildObject; _propertyPicker = propertyPicker; }
public static void PrintUsage(IFluentCommandLineParser <CleanupSettings> parser) { Console.WriteLine("GitCleanup usage: -d <directory> -u <user> -p <password>"); Console.WriteLine("Extra options:"); foreach (var o in parser.Options) { Console.WriteLine($"{"",-3}-{o.ShortName}, --{o.LongName,-10} : {o.Description}"); } }
public CommandLineParser(IFluentCommandLineParser parser) { if (parser == null) { throw new ArgumentNullException(nameof(parser)); } _parser = parser; }
private void ExtractCommandLineParametersIntoObject(ICommandLineParserResult parseResult, IFluentCommandLineParser <CommandLineInputParameters> inputArguments) { _commandLineInputParameters = inputArguments.Object; if (_commandLineInputParameters.IsInputInCSVFormat) { _csvParameters = _mapper.Map <CSVParameters>(_commandLineInputParameters); } _employeeDetailsInput = _mapper.Map <EmployeeDetailsInput>(_commandLineInputParameters); }
/// <summary> /// Returns a nicely-formatted string of options information for the given parser /// </summary> public static string GetPrettyOptionsText <T>(IFluentCommandLineParser <T> parser) where T : new() { const string optionLeftPad = " "; var maxWidth = Console.WindowWidth; var b = new StringBuilder(); var descriptionLeftMargin = parser.Options.Max(o => optionLeftPad.Length + GetParametersString(o).Length + 2); foreach (var o in parser.Options) { b.Append((optionLeftPad + GetParametersString(o)).PadRight(descriptionLeftMargin)); b.Append(Wrap(o.Description, descriptionLeftMargin, maxWidth)).AppendLine(); } return(b.ToString()); }
protected void SetupOption( IFluentCommandLineParser parser, string name, string description, string configSetting, Action <string> callback, bool isRequired = true) { var option = parser.Setup <string>(name).WithDescription(description).Callback(callback); var configSettingValue = _settings.GetApplicationSetting(configSetting); if (!string.IsNullOrEmpty(configSettingValue)) { option.SetDefault(configSettingValue); } else if (isRequired) { option.Required(); } }
private static AppOptions ProcessArgs(IFluentCommandLineParser <AppOptions> parser, string[] args) { var result = parser.Parse(args); var exit = result.HelpCalled; if (result.HasErrors) { Console.WriteLine(Usage); exit = true; } if (!File.Exists(parser.Object.TagsFileName)) { Console.WriteLine("File not found"); exit = true; } if (exit) { Application.Exit(); } return(parser.Object); }
public CommandLineCommand(IFluentCommandLineParser parser) { Parser = parser; Object = new TBuildType(); }
/// <summary> /// Initialises a new instance of the <see cref="NoDuplicateOptionValidator"/> class. /// </summary> /// <param name="parser">The <see cref="IFluentCommandLineParser"/> containing the setup options. This must not be null.</param> public NoDuplicateOptionValidator(IFluentCommandLineParser parser) { if (parser == null) throw new ArgumentNullException("parser"); _parser = parser; }