<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Abstractions;
using System.IO.Compression;
using System.Linq;
using System.Text;
using GitIgnorer;

namespace srcbackup
{
    public class Program
    {
        private static readonly FileSystem FileSystem = new FileSystem();
        private static readonly GitIgnoreCompiler GitIgnoreCompiler = new GitIgnoreCompiler(FileSystem);

        public static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: srcbackup.exe <source-directory> <output-zip-file>");
                return;
            }

            var sw = Stopwatch.StartNew();

            var rootPath = args[0].TrimEnd('\\', '/') + '\\';
            var zipPath = args[1];
            var files = GetFiles(rootPath, null);

            var outputDirectory = Path.GetDirectoryName(zipPath);
            if(!string.IsNullOrEmpty(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            Console.Write("Creating archive for all files in \"{0}\" not ignored by GIT", rootPath);

            Console.CursorVisible = false;
            var n = CreateZipArchive(files, rootPath, zipPath);
            Console.CursorVisible = true;

            sw.Stop();
<commit_msg>feat(*): adds -t parameter for adding a timestamp to the output filename<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using System.IO.Compression;
using System.Linq;
using System.Text;
using GitIgnorer;

namespace srcbackup
{
    public class Program
    {
        private static readonly FileSystem FileSystem = new FileSystem();
        private static readonly GitIgnoreCompiler GitIgnoreCompiler = new GitIgnoreCompiler(FileSystem);

        public static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: srcbackup.exe <source-directory> <output-zip-file> [-t]");
                return;
            }

            var rootPath = args[0].TrimEnd('\\', '/') + '\\';
            var zipPath = args[1];

            if (args.Length == 3 && args[2].Equals("-t", StringComparison.InvariantCultureIgnoreCase))
            {
                zipPath = zipPath.Insert(zipPath.Length - 4, DateTime.Now.ToString("_yyyyMMddHHmmss", CultureInfo.InvariantCulture));
            }

            var outputDirectory = Path.GetDirectoryName(zipPath);
            if(!string.IsNullOrEmpty(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            Console.Write("Creating archive for all files in \"{0}\" not ignored by GIT", rootPath);

            Console.CursorVisible = false;
            var sw = Stopwatch.StartNew();
            var n = CreateZipArchive(GetFiles(rootPath, null), rootPath, zipPath);
            sw.Stop();
            Console.CursorVisible = true;

{'fraction_non_alphanumeric': 0.10471881060116355, 'fraction_numerical': 0.003555268261150614, 'mean_word_length': 2.2890541976620615, 'pattern_counts': {'":': 0, '<': 8, '<?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': '3795057', 'n_tokens_mistral': 814, 'n_tokens_neox': 783, 'n_words': 201}