Пример #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="CommandLine.Text.HelpText"/> class using common defaults.
        /// </summary>
        /// <returns>
        /// An instance of <see cref="CommandLine.Text.HelpText"/> class.
        /// </returns>
        /// <param name='options'>The instance that collected command line arguments parsed with <see cref="CommandLine.CommandLineParser"/> class.</param>
        /// <param name='errDelegate'>A delegate used to customize the text block for reporting parsing errors.</param>
        /// <param name="verbsIndex">If true the output style is consistent with verb commands (no dashes), otherwise it outputs options.</param>
        public static HelpText AutoBuild(object options, ParsingErrorsHandler errDelegate, bool verbsIndex)
        {
            var auto = new HelpText {
                Heading = HeadingInfo.Default,
                Copyright = CopyrightInfo.Default,
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = !verbsIndex };

            if (errDelegate != null)
            {
                var list = ReflectionUtil.RetrievePropertyList<ParserStateAttribute>(options);
                if (list != null)
                {
                    errDelegate(auto);
                }
            }

            var license = ReflectionUtil.GetAttribute<AssemblyLicenseAttribute>();
            if (license != null)
            {
                license.AddToHelpText(auto, true);
            }
            var usage = ReflectionUtil.GetAttribute<AssemblyUsageAttribute>();
            if (usage != null)
            {
                usage.AddToHelpText(auto, true);
            }

            auto.AddOptions(options);

            return auto;
        }
Пример #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="CommandLine.Text.HelpText"/> class using common defaults.
 /// </summary>
 /// <returns>
 /// An instance of <see cref="CommandLine.Text.HelpText"/> class.
 /// </returns>
 /// <param name='options'>The instance that collected command line arguments parsed with <see cref="CommandLine.CommandLineParser"/> class.</param>
 /// <param name='errDelegate'>A delegate used to customize the text block for reporting parsing errors.</param>
 public static HelpText AutoBuild(object options, ParsingErrorsHandler errDelegate)
 {
     return AutoBuild(options, errDelegate, false);
 }