protected void BurstToken(Options options, string token, bool stopAtNonOption) { for (int i = 1; i < token.Length; i++) { String ch = token[i].ToString(); if (options.HasOption(ch)) { tokens.Add("-" + ch); currentOption = options.GetOption(ch); if (currentOption.HasArgument() && (token.Length != (i + 1))) { tokens.Add(token.Substring(i + 1)); break; } } else if (stopAtNonOption) { ProcessNonOptionToken(token.Substring(i), true); break; } else { tokens.Add(token); break; } } }
private void ProcessNonOptionToken(String value, bool stopAtNonOption) { if (stopAtNonOption && (currentOption == null || !currentOption.HasArgument())) { eatTheRest = true; tokens.Add("--"); } tokens.Add(value); }
protected void ProcessProperties(IOptions options, IEnumerable <KeyValuePair <string, string> > properties) { if (properties == null) { return; } foreach (KeyValuePair <string, string> option in properties) { if (!cmd.HasOption(option.Key)) { IOption opt = options.GetOption(option.Key); // get the value from the properties instance var value = option.Value; OptionValue optValue = null; if (opt.HasArgument()) { optValue = SafeGetOptionValue(opt); if (optValue.Values == null || !optValue.Values.Any()) { try { optValue.AddValueForProcessing(value); } catch (ApplicationException) { // if we cannot add the value don't worry about it } } } else if (String.Compare(value, "yes", StringComparison.OrdinalIgnoreCase) != 0 && String.Compare(value, "true", StringComparison.OrdinalIgnoreCase) != 0 && String.Compare(value, "1", StringComparison.OrdinalIgnoreCase) != 0) { // if the value is not yes, true or 1 then don't add the // option to the CommandLine break; } cmd.AddOption(optValue); } } }
protected void BurstToken(Options options, string token, bool stopAtNonOption) { for (int i = 1; i < token.Length; i++) { String ch = token[i].ToString(); if (options.HasOption(ch)) { tokens.Add("-" + ch); currentOption = options.GetOption(ch); if (currentOption.HasArgument() && (token.Length != (i + 1))) { tokens.Add(token.Substring(i + 1)); break; } } else if (stopAtNonOption) { ProcessNonOptionToken(token.Substring(i), true); break; } else { tokens.Add(token); break; } } }