diff --git a/src/MdDocs.CommandLineHelp/Commands/CommandLineHelpCommand.cs b/src/MdDocs.CommandLineHelp/Commands/CommandLineHelpCommand.cs index 06b3896b..74c48bec 100644 --- a/src/MdDocs.CommandLineHelp/Commands/CommandLineHelpCommand.cs +++ b/src/MdDocs.CommandLineHelp/Commands/CommandLineHelpCommand.cs @@ -38,7 +38,7 @@ public bool Execute() .Render(model) .Save( m_Configuration.OutputPath, - cleanOutputDirectory: true, + cleanOutputDirectory: m_Configuration.ShouldDeleteOutputPathBeforeGeneration, markdownOptions: m_Configuration.Template.Default.GetSerializationOptions(m_Logger) ); diff --git a/src/MdDocs.CommandLineHelp/Configuration/CommandLineHelpConfiguration.cs b/src/MdDocs.CommandLineHelp/Configuration/CommandLineHelpConfiguration.cs index d1253ed2..6d69bfc8 100644 --- a/src/MdDocs.CommandLineHelp/Configuration/CommandLineHelpConfiguration.cs +++ b/src/MdDocs.CommandLineHelp/Configuration/CommandLineHelpConfiguration.cs @@ -11,12 +11,16 @@ public enum TemplateName public class DefaultTemplateConfiguration : IConfigurationWithMarkdownPresetSetting { + public const string s_DefaultApplicationMdFileName = "index.md"; + public bool IncludeVersion { get; set; } public bool IncludeAutoGeneratedNotice { get; set; } public MarkdownPreset MarkdownPreset { get; set; } = MarkdownPreset.Default; + public string ApplicationMdFileName { get; set; } = s_DefaultApplicationMdFileName; + } public class TemplateConfiguration @@ -33,6 +37,8 @@ public class TemplateConfiguration [ConvertToFullPath] public string AssemblyPath { get; set; } = ""; + public bool ShouldDeleteOutputPathBeforeGeneration { get; set; } = true; + public TemplateConfiguration Template { get; set; } = new TemplateConfiguration(); } } diff --git a/src/MdDocs.CommandLineHelp/Templates/CommandLineHelpTemplateProvider.cs b/src/MdDocs.CommandLineHelp/Templates/CommandLineHelpTemplateProvider.cs index 52180dee..8bcdb016 100644 --- a/src/MdDocs.CommandLineHelp/Templates/CommandLineHelpTemplateProvider.cs +++ b/src/MdDocs.CommandLineHelp/Templates/CommandLineHelpTemplateProvider.cs @@ -13,7 +13,7 @@ public static ITemplate GetTemplate(ILogger logger, Co switch (configuration.Template.Name) { case CommandLineHelpConfiguration.TemplateName.Default: - return new CommandLineHelpDefaultTemplate(configuration, new DefaultCommandLineHelpPathProvider(), logger); + return new CommandLineHelpDefaultTemplate(configuration, new DefaultCommandLineHelpPathProvider(configuration.Template.Default.ApplicationMdFileName), logger); default: throw new InvalidTemplateConfigurationException($"Unknown template '{configuration.Template.Name}'"); diff --git a/src/MdDocs.CommandLineHelp/Templates/Default/_PathProvider/DefaultCommandLineHelpPathProvider.cs b/src/MdDocs.CommandLineHelp/Templates/Default/_PathProvider/DefaultCommandLineHelpPathProvider.cs index de1a383a..77799978 100644 --- a/src/MdDocs.CommandLineHelp/Templates/Default/_PathProvider/DefaultCommandLineHelpPathProvider.cs +++ b/src/MdDocs.CommandLineHelp/Templates/Default/_PathProvider/DefaultCommandLineHelpPathProvider.cs @@ -1,10 +1,18 @@ -using Grynwald.MdDocs.CommandLineHelp.Model; +using Grynwald.MdDocs.CommandLineHelp.Configuration; +using Grynwald.MdDocs.CommandLineHelp.Model; namespace Grynwald.MdDocs.CommandLineHelp.Templates.Default { public class DefaultCommandLineHelpPathProvider : ICommandLineHelpPathProvider { - public string GetPath(ApplicationDocumentation model) => "index.md"; + private readonly string m_ApplicationDocumentationName; + + public DefaultCommandLineHelpPathProvider(string applicationDocumentationName = CommandLineHelpConfiguration.DefaultTemplateConfiguration.s_DefaultApplicationMdFileName) + { + m_ApplicationDocumentationName = applicationDocumentationName; + } + + public string GetPath(ApplicationDocumentation model) => m_ApplicationDocumentationName; public string GetPath(CommandDocumentation model) => $"commands/{model.Name}.md"; }