private void AppendParameter(StringBuilder sb, CommandLineParameterAttribute parameter, int maxWidth, int maxParameterWidth, int margin) { var nameLines = WrapText(FormatCommandLineParameter(parameter), maxParameterWidth + margin); var descriptionLines = WrapText(parameter.Description, maxWidth - maxParameterWidth - margin); AppendLines(sb, maxParameterWidth, nameLines, descriptionLines); }
private static string FormatCommandArgument(CommandLineParameterAttribute parameter) { if (parameter.ValueExample != null) { return(string.Format(parameter.Required ? "{0}{1}:{2} " : "[{0}{1}:{2}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command, parameter.ValueExample)); } else { return(string.Format(parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command)); } }
private void Load() { // Select all the CommandLineParameterAttribute attributes from all the properties on the type and create a command line parameter for it CommandLineParameterAttribute.ForEach(ArgumentType, Add); VerifyPositionalArgumentsInSequence(); // If there are no attributed properties if (Parameters.Count == 0) { // infer them based on the property names CommandLineParameterAttribute.ForEach(ArgumentType, InferCommandLineParameterAttribute, Add); } }
internal CommandLineParameter(PropertyInfo property, CommandLineParameterAttribute attribute) { this.Property = property; this.Attribute = attribute; this.Command = this.Attribute.Command; // Set the defaults if (property.PropertyType == typeof(bool)) { // If no switch is specified for bool properties then the name is the switch if (string.IsNullOrWhiteSpace(this.Command)) { this.Command = property.Name; } } }
public CommandArgumentHelp(Type argumentClassType, string message) { this.Message = message; var cmdLineAttribute = CommandLineArgumentsAttribute.Get(argumentClassType); if (cmdLineAttribute != null) { this.Title = cmdLineAttribute.Title; this.Description = cmdLineAttribute.Description; this.Program = cmdLineAttribute.Program; } foreach (var parameterAttribute in CommandLineParameterAttribute.GetAllPropertyParameters(argumentClassType)) { this.validArguments.Add(parameterAttribute); } }
private static bool IsParameter(CommandLineParameterAttribute parameter) { return(parameter.IsParameter()); }
private void AppendParameter( StringBuilder sb, CommandLineParameterAttribute parameter, int maxWidth, int maxParameterWidth, int margin) { var nameLines = WrapText(FormatCommandLineParameter(parameter), maxParameterWidth + margin); var descriptionLines = WrapText(parameter.Description, maxWidth - maxParameterWidth - margin); AppendLines(sb, maxParameterWidth, nameLines, descriptionLines); }
private static int ParameterIndex(CommandLineParameterAttribute parameter) { return parameter.ParameterIndex; }
private static bool IsParameter(CommandLineParameterAttribute parameter) { return parameter.IsParameter(); }
private static string FormatParameterArgument(CommandLineParameterAttribute parameter) { return string.Format(parameter.Required ? "{0} " : "[{0}] ", parameter.Name); }
private static string FormatCommandLineParameter(CommandLineParameterAttribute parameter) { return parameter.IsCommand() ? FormatCommandArgument(parameter) : FormatParameterArgument(parameter); }
private static string FormatCommandArgument(CommandLineParameterAttribute parameter) { return string.Format( parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command); }
private static string CommandName(CommandLineParameterAttribute parameter) { return parameter.Command; }
private static int ParameterIndex(CommandLineParameterAttribute parameter) { return(parameter.ParameterIndex); }
private static string FormatCommandArgument(CommandLineParameterAttribute parameter) { if (parameter.ValueExample != null) return string.Format(parameter.Required ? "{0}{1}:{2} " : "[{0}{1}:{2}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command, parameter.ValueExample); else return string.Format(parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command); }
private static string FormatParameterArgument(CommandLineParameterAttribute parameter) { return(string.Format(parameter.Required ? "{0} " : "[{0}] ", parameter.Name)); }
private static string FormatCommandLineParameter(CommandLineParameterAttribute parameter) { return(parameter.IsCommand() ? FormatCommandArgument(parameter) : FormatParameterArgument(parameter)); }
private static string FormatCommandArgument(CommandLineParameterAttribute parameter) { return(string.Format( parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(), parameter.Command)); }
private static string CommandName(CommandLineParameterAttribute parameter) { return(parameter.Command); }