<commit_before>﻿using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using CommandLine;
using CommandLine.Text;
using Microsoft.Build.Framework;

namespace CitizenMP.Server.Installer
{
    internal class CommandLineOptions
    {
        [Option('v', "verbosity", DefaultValue = LoggerVerbosity.Quiet, HelpText = "Sets the build output verbosity. Possible values: Minimal, Quiet, Normal, Detailed, Diagnostic")]
        public LoggerVerbosity Verbosity { get; set; }

        [Option("source", DefaultValue = "src", HelpText = "Sets the path where the source files will be stored.")]
        public string SourceDir { get; set; }

        [Option("log", DefaultValue = true, HelpText = "Write a log file \"build.log\" to the output folder.")]
        public bool WriteLogFile { get; set; }

        [ValueOption(0)]
        public string OutputPath { get; set; }

        [HelpOption]
        public string GetUsage()
        {
            var programInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var assembly = Assembly.GetExecutingAssembly();

            var help = new HelpText
            {
                AddDashesToOption = true,
                AdditionalNewLineAfterOption = true,
                Copyright = programInfo.LegalCopyright,
                Heading = new HeadingInfo(programInfo.ProductName, programInfo.ProductVersion),
                MaximumDisplayWidth = Console.BufferWidth
            };

            var errors = help.RenderParsingErrorsText(this, 2);
            if (!string.IsNullOrEmpty(errors))
            {
                help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
                help.AddPreOptionsLine(errors);
            }

            help.AddPreOptionsLine(" ");
#if !NO_COMMANDLINE
            help.AddPreOptionsLine(((AssemblyLicenseAttribute)assembly
                .GetCustomAttributes(typeof(AssemblyLicenseAttribute), false)
                .Single()).Value.Trim());
#else
            help.AddPreOptionsLine(
                "This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
#endif
            help.AddPreOptionsLine(" ");
            help.AddPreOptionsLine(string.Format("{0}{1} [options...] \"<targetpath>\"",
                Process.GetCurrentProcess().ProcessName,
                new FileInfo(Assembly.GetExecutingAssembly().Location).Extension));

            help.AddOptions(this);

            return help.ToString();<commit_msg>Fix process name display on usage output. The extension is not really needed if it crashes Mono after merging that much.<commit_after>﻿using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using CommandLine;
using CommandLine.Text;
using Microsoft.Build.Framework;

namespace CitizenMP.Server.Installer
{
    internal class CommandLineOptions
    {
        [Option('v', "verbosity", DefaultValue = LoggerVerbosity.Quiet, HelpText = "Sets the build output verbosity. Possible values: Minimal, Quiet, Normal, Detailed, Diagnostic")]
        public LoggerVerbosity Verbosity { get; set; }

        [Option("source", DefaultValue = "src", HelpText = "Sets the path where the source files will be stored.")]
        public string SourceDir { get; set; }

        [Option("log", DefaultValue = true, HelpText = "Write a log file \"build.log\" to the output folder.")]
        public bool WriteLogFile { get; set; }

        [ValueOption(0)]
        public string OutputPath { get; set; }

        [HelpOption]
        public string GetUsage()
        {
            var programInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var assembly = Assembly.GetExecutingAssembly();

            var help = new HelpText
            {
                AddDashesToOption = true,
                AdditionalNewLineAfterOption = true,
                Copyright = programInfo.LegalCopyright,
                Heading = new HeadingInfo(programInfo.ProductName, programInfo.ProductVersion),
                MaximumDisplayWidth = Console.BufferWidth
            };

            var errors = help.RenderParsingErrorsText(this, 2);
            if (!string.IsNullOrEmpty(errors))
            {
                help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
                help.AddPreOptionsLine(errors);
            }

            help.AddPreOptionsLine(" ");
#if !NO_COMMANDLINE
            help.AddPreOptionsLine(((AssemblyLicenseAttribute)assembly
                .GetCustomAttributes(typeof(AssemblyLicenseAttribute), false)
                .Single()).Value.Trim());
#else
            help.AddPreOptionsLine(
                "This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
#endif
            help.AddPreOptionsLine(" ");
            help.AddPreOptionsLine(string.Format("{0} [options...] \"<targetpath>\"",
                Process.GetCurrentProcess().ProcessName));

            help.AddOptions(this);

            return help.ToString();
{'fraction_non_alphanumeric': 0.10148798168637925, 'fraction_numerical': 0.0013353681800839375, 'mean_word_length': 2.528263795423957, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7466559', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1286, 'n_words': 335}