private string Usage(Type type) { VerbAttribute verbAttr = type.GetCustomAttributes <VerbAttribute>().FirstOrDefault(); var options = OptionsClassProcessor.GetOptions(type); var values = OptionsClassProcessor.GetValues(type); var restOfInput = OptionsClassProcessor.GetRestOfInputProperty(type); StringBuilder result = new StringBuilder(); if (verbAttr != null) { result.AppendLine(verbAttr.HelpText.SplitToLines(LineWidth + 20, 0) + Environment.NewLine); } foreach (var option in options.Values) { result.AppendFormat("{0,-20} {1}" + Environment.NewLine, (option.IsShortOption ? "-" : "--") + option.Option, option.Description.SplitToLines(LineWidth, PrepadSpaces)); } foreach (var value in values.Values.OrderBy(v => v.Index)) { result.AppendFormat("#{0,-19} {1}" + Environment.NewLine, value.Index, value.Description.SplitToLines(LineWidth, PrepadSpaces)); } if (restOfInput != null) { result.AppendFormat("{0,-20} {1}" + Environment.NewLine, "rest of input", restOfInput.Item2.Description.SplitToLines(LineWidth, PrepadSpaces)); } return(result.ToString()); }