示例#1
0
        /// <summary>
        /// The DotBook entry point.
        /// </summary>
        /// <param name="args">Command line args</param>
        public static void Main(string[] args)
        {
            var p   = new ArgParser();
            var arg = new ApplicationArguments();

            p.UseOwnOptionPrefix("-", "--");
            p.Setup(v => arg.OutputDirectory = string.Join(" ", v))
            .As('o', "output")
            .SetDefault("docs")
            .WithDescription("Output directory for the generated documentation. " +
                             "If not specified, defaults to 'docs'.");

            p.Setup(v => arg.InputDirectory = string.Join(" ", v))
            .As('s', "src")
            .WithDescription("Directory for C# code search");

            p.Setup(v => arg.Visibility = v.ToEnum <Modifier>())
            .As('v', "visibility")
            .SetDefault("public")
            .WithDescription("Include types and members with the specified " +
                             "visibilities. Defaults to 'public'.");

            p.Setup(v => bool.Parse(v.FirstOrDefault() ?? "true"))
            .As('h', "use-hash")
            .SetDefault("false")
            .WithDescription("Use hashing for documentation filenames to " +
                             "allow deep hierarchies. " +
                             "If false, uses escaped type/member name. " +
                             "Defaults to 'false'.");

            p.Setup(v => arg.Format = v.ToEnum <FileFormat>().First())
            .As('f', "format")
            .SetDefault("Markdown")
            .WithDescription("Sets the output format. Default is Markdown. " +
                             "Available formats: Markdown, Html");

            p.SetupHelp("?", "help")
            .Callback(v =>
            {
                Console.WriteLine(string.Join("\n", p.GetHelp()));
                Environment.Exit(0);
            });

            p.Parse(args);

            try
            {
                Info("Using the following parameters:");
                Log($"{arg}");
                Run(arg);
            }
            catch (PathTooLongException pex)
            {
                Fatal("Hierarchy is too deep to use type/member names " +
                      "as filenames. Try using the --use-hash flag." +
                      $"{pex}");
            }
        }