コード例 #1
0
        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);
        }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
            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);
                }
            }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
        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;
                }
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 private static bool IsParameter(CommandLineParameterAttribute parameter)
 {
     return(parameter.IsParameter());
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 private static int ParameterIndex(CommandLineParameterAttribute parameter)
 {
     return parameter.ParameterIndex;
 }
コード例 #10
0
 private static bool IsParameter(CommandLineParameterAttribute parameter)
 {
     return parameter.IsParameter();
 }
コード例 #11
0
 private static string FormatParameterArgument(CommandLineParameterAttribute parameter)
 {
     return string.Format(parameter.Required ? "{0} " : "[{0}] ", parameter.Name);
 }
コード例 #12
0
 private static string FormatCommandLineParameter(CommandLineParameterAttribute parameter)
 {
     return parameter.IsCommand() ? FormatCommandArgument(parameter) : FormatParameterArgument(parameter);
 }
コード例 #13
0
 private static string FormatCommandArgument(CommandLineParameterAttribute parameter)
 {
     return string.Format(
         parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(),
         parameter.Command);
 }
コード例 #14
0
 private static string CommandName(CommandLineParameterAttribute parameter)
 {
     return parameter.Command;
 }
コード例 #15
0
 private static int ParameterIndex(CommandLineParameterAttribute parameter)
 {
     return(parameter.ParameterIndex);
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 private static string FormatParameterArgument(CommandLineParameterAttribute parameter)
 {
     return(string.Format(parameter.Required ? "{0} " : "[{0}] ", parameter.Name));
 }
コード例 #18
0
 private static string FormatCommandLineParameter(CommandLineParameterAttribute parameter)
 {
     return(parameter.IsCommand() ? FormatCommandArgument(parameter) : FormatParameterArgument(parameter));
 }
コード例 #19
0
 private static string FormatCommandArgument(CommandLineParameterAttribute parameter)
 {
     return(string.Format(
                parameter.Required ? "{0}{1} " : "[{0}{1}] ", CmdLine.CommandLine.CommandSeparators.First(),
                parameter.Command));
 }
コード例 #20
0
 private static string CommandName(CommandLineParameterAttribute parameter)
 {
     return(parameter.Command);
 }