<commit_before>using System;
using System.IO;
using Baseline;
using Oakton;

namespace Marten.CommandLine.Commands.Dump
{
    [Description("Dumps the entire DDL for the configured Marten database")]
    public class DumpCommand: MartenCommand<DumpInput>
    {
        public DumpCommand()
        {
            Usage("Writes the complete DDL for the entire Marten configuration to the named file")
                .Arguments(x => x.FileName);
        }

        protected override bool execute(IDocumentStore store, DumpInput input)
        {
            if (input.ByTypeFlag)
            {
                input.WriteLine("Writing DDL files to " + input.FileName);
                store.Schema.WriteDDLByType(input.FileName, input.TransactionalScriptFlag);
            }
            else
            {
                input.WriteLine("Writing DDL file to " + input.FileName);

                try
                {
                    var directory = Path.GetDirectoryName(input.FileName);
                    if (Directory.Exists(directory))
                    {
                        new FileSystem().CleanDirectory(directory);
                    }
                }
                catch (Exception)
                {
                    input.WriteLine(ConsoleColor.Yellow, $"Unable to clean the directory at {input.FileName} before writing new files");
                }

                store.Schema.WriteDDL(input.FileName, input.TransactionalScriptFlag);
            }

            return true;
        }<commit_msg>another change to only 'clean' the directory when exporting by type<commit_after>using System;
using System.IO;
using Baseline;
using Oakton;

namespace Marten.CommandLine.Commands.Dump
{
    [Description("Dumps the entire DDL for the configured Marten database")]
    public class DumpCommand: MartenCommand<DumpInput>
    {
        public DumpCommand()
        {
            Usage("Writes the complete DDL for the entire Marten configuration to the named file")
                .Arguments(x => x.FileName);
        }

        protected override bool execute(IDocumentStore store, DumpInput input)
        {
            if (input.ByTypeFlag)
            {
                input.WriteLine("Writing DDL files to " + input.FileName);
                store.Schema.WriteDDLByType(input.FileName, input.TransactionalScriptFlag);

                // You only need to clean out the existing folder when dumping
                // by type
                try
                {
                    if (Directory.Exists(input.FileName))
                    {
                        new FileSystem().CleanDirectory(input.FileName);
                    }
                }
                catch (Exception)
                {
                    input.WriteLine(ConsoleColor.Yellow, $"Unable to clean the directory at {input.FileName} before writing new files");
                }
            }
            else
            {
                input.WriteLine("Writing DDL file to " + input.FileName);



                store.Schema.WriteDDL(input.FileName, input.TransactionalScriptFlag);
            }

            return true;
        }
{'fraction_non_alphanumeric': 0.07606973058637084, 'fraction_numerical': 0.0, 'mean_word_length': 1.5616883116883118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7053834', 'n_tokens_mistral': 771, 'n_tokens_neox': 716, 'n_words': 196}