<commit_before>﻿using LSLib.LS.Story;
using System;
using System.IO;
using CommandLineParser.Exceptions;
using System.Collections.Generic;
using LSLib.LS.Story.Compiler;

namespace LSTools.StoryCompiler
{
    class Program
    {
        static void DebugDump(string storyPath, string debugPath)
        {
            Story story;
            using (var file = new FileStream(storyPath, FileMode.Open, FileAccess.Read))
            {
                var reader = new StoryReader();
                story = reader.Read(file);
            }
            
            using (var debugFile = new FileStream(debugPath, FileMode.Create, FileAccess.Write))
            {
                using (var writer = new StreamWriter(debugFile))
                {
                    story.DebugDump(writer);
                }
            }
        }

        static void Run(CommandLineArguments args)
        {
            Logger logger;
            if (args.JsonOutput)
            {
                logger = new JsonLogger();
            }
            else
            {
                logger = new ConsoleLogger();
            }
            
            var modCompiler = new ModCompiler(logger, args.GameDataPath);
            modCompiler.SetWarningOptions(CommandLineArguments.GetWarningOptions(args.Warnings));
            modCompiler.CheckGameObjects = args.CheckGameObjects;
            modCompiler.CheckOnly = args.CheckOnly;
            modCompiler.LoadPackages = !args.NoPackages;
            if (args.Game == "dos2")
            {
                modCompiler.Game = TargetGame.DOS2;
            }
            else if (args.Game == "dos2de")
            {
                modCompiler.Game = TargetGame.DOS2DE;
            }
            else
            {
                throw new ArgumentException("Unsupported game type");
            }

            var mods = new List<string>(args.Mods);
            if (!modCompiler.Compile(args.OutputPath, args.DebugInfoOutputPath, mods))
            {
                Environment.Exit(3);
            }

            if (args.DebugLogOutputPath != null)
            {
                DebugDump(args.OutputPath, args.DebugLogOutputPath);
            }
        }

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: StoryCompiler <args>");
                Console.WriteLine("    --game-data-path <path> - Location of the game Data folder");
                Console.WriteLine("    --output <path>         - Compiled story output path");
                Console.WriteLine("    --debug-info <path>     - Debugging symbols path");
                Console.WriteLine("    --debug-log <path>      - Debug output log path");
                Console.WriteLine("    --mod <name>            - Check and compile all goals from the specified mod");
                Console.WriteLine("    --no-warn <code>        - Suppress warnings with diagnostic code <code>");
                Console.WriteLine("    --check-only            - Only check scripts for errors, don't generate compiled story file");
                Console.WriteLine("    --check-names           - Verify game object names (slow!)");
                Environment.Exit(1);
            }

            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();

            var argv = new CommandLineArguments();

            parser.ExtractArgumentAttributes(argv);

            try
            {
                parser.ParseCommandLine(args);
            }
            catch (CommandLineArgumentException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Argument --{e.Argument}: {e.Message}");
                Console.ResetColor();
                Environment.Exit(1);
            }
            catch (CommandLineException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ResetColor();
                Environment.Exit(1);
            }
<commit_msg>Update usage in story compiler<commit_after>﻿using LSLib.LS.Story;
using System;
using System.IO;
using CommandLineParser.Exceptions;
using System.Collections.Generic;
using LSLib.LS.Story.Compiler;

namespace LSTools.StoryCompiler
{
    class Program
    {
        static void DebugDump(string storyPath, string debugPath)
        {
            Story story;
            using (var file = new FileStream(storyPath, FileMode.Open, FileAccess.Read))
            {
                var reader = new StoryReader();
                story = reader.Read(file);
            }
            
            using (var debugFile = new FileStream(debugPath, FileMode.Create, FileAccess.Write))
            {
                using (var writer = new StreamWriter(debugFile))
                {
                    story.DebugDump(writer);
                }
            }
        }

        static void Run(CommandLineArguments args)
        {
            Logger logger;
            if (args.JsonOutput)
            {
                logger = new JsonLogger();
            }
            else
            {
                logger = new ConsoleLogger();
            }
            
            var modCompiler = new ModCompiler(logger, args.GameDataPath);
            modCompiler.SetWarningOptions(CommandLineArguments.GetWarningOptions(args.Warnings));
            modCompiler.CheckGameObjects = args.CheckGameObjects;
            modCompiler.CheckOnly = args.CheckOnly;
            modCompiler.LoadPackages = !args.NoPackages;
            if (args.Game == "dos2")
            {
                modCompiler.Game = TargetGame.DOS2;
            }
            else if (args.Game == "dos2de")
            {
                modCompiler.Game = TargetGame.DOS2DE;
            }
            else
            {
                throw new ArgumentException("Unsupported game type");
            }

            var mods = new List<string>(args.Mods);
            if (!modCompiler.Compile(args.OutputPath, args.DebugInfoOutputPath, mods))
            {
                Environment.Exit(3);
            }

            if (args.DebugLogOutputPath != null)
            {
                DebugDump(args.OutputPath, args.DebugLogOutputPath);
            }
        }

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: StoryCompiler <args>");
                Console.WriteLine("    --game-data-path <path> - Location of the game Data folder");
                Console.WriteLine("    --game <dos2|dos2de>    - Which game to target during compilation");
                Console.WriteLine("    --output <path>         - Compiled story output path");
                Console.WriteLine("    --debug-info <path>     - Debugging symbols path");
                Console.WriteLine("    --debug-log <path>      - Debug output log path");
                Console.WriteLine("    --mod <name>            - Check and compile all goals from the specified mod");
                Console.WriteLine("    --no-warn <code>        - Suppress warnings with diagnostic code <code>");
                Console.WriteLine("    --check-only            - Only check scripts for errors, don't generate compiled story file");
                Console.WriteLine("    --check-names           - Verify game object names (slow!)");
                Console.WriteLine("    --no-packages           - Don't load files from packages");
                Environment.Exit(1);
            }

            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();

            var argv = new CommandLineArguments();

            parser.ExtractArgumentAttributes(argv);

            try
            {
                parser.ParseCommandLine(args);
            }
            catch (CommandLineArgumentException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Argument --{e.Argument}: {e.Message}");
                Console.ResetColor();
                Environment.Exit(1);
            }
            catch (CommandLineException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ResetColor();
                Environment.Exit(1);
            }

{'fraction_non_alphanumeric': 0.09322435441838427, 'fraction_numerical': 0.002369106846718787, 'mean_word_length': 1.442291003760486, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '3676605', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1958, 'n_words': 454}