<commit_before>﻿/*
Helpers.cs

This file is part of Morgan's CLR Advanced Runtime (MCART)

Author(s):
     <NAME> <<EMAIL>>

Copyright © 2011 - 2019 <NAME>

Morgan's CLR Advanced Runtime (MCART) is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

Morgan's CLR Advanced Runtime (MCART) is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

#nullable enable

using System;
using System.Linq;
using TheXDS.MCART.Component;
using static TheXDS.MCART.Resources.CmdStrings;

namespace TheXDS.MCART.Types.Extensions
{
    /// <summary>
    ///     Extensiones para administrar un <see cref="CmdLineParser"/> bajo la
    ///     interfaz de terminal/consola.
    /// </summary>
    public static class CmdLineParserExtensions
    {
        /// <summary>
        ///     Genera una pantalla de ayuda con los argumentos registrados en
        ///     el <see cref="CmdLineParser"/> especificado.
        /// </summary>
        /// <param name="args">
        ///     Instancia de <see cref="CmdLineParser"/> desde la cual extraer
        ///     la información de ayuda de los argumentos.
        /// </param>
        public static void PrintHelp(this CmdLineParser args)
        {
            IExposeInfo nfo = new AssemblyInfo(ReflectionHelpers.GetEntryPoint().DeclaringType.Assembly);
            Cmd.Helpers.About(nfo);

            var width = args.AvailableArguments.Max(p => p.LongName.Length);
            foreach (var j in args.AvailableArguments)
            {
                Console.Write($"  /{j.LongName.PadRight(width)}  - ");
                var _1st = false;
                foreach (var k in (j.Summary ?? string.Empty).TextWrap(Console.BufferWidth - (width + 7)))
                {
                    if (_1st)
                    {
                        Console.Write(new string(' ', width + 7));
                    }
                    _1st = true;
                    Console.WriteLine(k);
                }
                Console.WriteLine();
            }
        }

        /// <summary>
        ///     Ejecuta automáticamente las tareas asociadas a una lista de
        ///     argumentos.
        /// </summary>
        /// <param name="args">
        ///     Instancia de <see cref="CmdLineParser"/> con los argumentos a
        ///     ejecutar.
        /// </param>
        /// <param name="exitIfInvalidArgs">
        ///     Si se establece en <see langword="true"/>, la aplicación será
        ///     finalizada si existen argumentos inválidos, faltan argumentos
        ///     requeridos o si ocurre un error en una de las operaciones.
        /// </param>
        public static void AutoRun(this CmdLineParser args, bool exitIfInvalidArgs)
        {
            if (args.Invalid.Any())
            {
                foreach (var j in args.Invalid)<commit_msg>Fix menor de texto en consola<commit_after>﻿/*
Helpers.cs

This file is part of Morgan's CLR Advanced Runtime (MCART)

Author(s):
     <NAME> <<EMAIL>>

Copyright © 2011 - 2019 <NAME>

Morgan's CLR Advanced Runtime (MCART) is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

Morgan's CLR Advanced Runtime (MCART) is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

#nullable enable

using System;
using System.Linq;
using TheXDS.MCART.Component;
using static TheXDS.MCART.Resources.CmdStrings;

namespace TheXDS.MCART.Types.Extensions
{
    /// <summary>
    ///     Extensiones para administrar un <see cref="CmdLineParser"/> bajo la
    ///     interfaz de terminal/consola.
    /// </summary>
    public static class CmdLineParserExtensions
    {
        /// <summary>
        ///     Genera una pantalla de ayuda con los argumentos registrados en
        ///     el <see cref="CmdLineParser"/> especificado.
        /// </summary>
        /// <param name="args">
        ///     Instancia de <see cref="CmdLineParser"/> desde la cual extraer
        ///     la información de ayuda de los argumentos.
        /// </param>
        public static void PrintHelp(this CmdLineParser args)
        {
            IExposeInfo nfo = new AssemblyInfo(ReflectionHelpers.GetEntryPoint().DeclaringType.Assembly);
            Cmd.Helpers.About(nfo);

            var width = args.AvailableArguments.Max(p => p.LongName.Length);
            foreach (var j in args.AvailableArguments)
            {
                Console.Write($"  /{j.LongName.PadRight(width)}  - ");
                var _1st = false;
                foreach (var k in (j.Summary ?? string.Empty).TextWrap(Console.BufferWidth - (width + 8)))
                {
                    if (_1st)
                    {
                        Console.Write(new string(' ', width + 7));
                    }
                    _1st = true;
                    Console.WriteLine(k);
                }
                Console.WriteLine();
            }
        }

        /// <summary>
        ///     Ejecuta automáticamente las tareas asociadas a una lista de
        ///     argumentos.
        /// </summary>
        /// <param name="args">
        ///     Instancia de <see cref="CmdLineParser"/> con los argumentos a
        ///     ejecutar.
        /// </param>
        /// <param name="exitIfInvalidArgs">
        ///     Si se establece en <see langword="true"/>, la aplicación será
        ///     finalizada si existen argumentos inválidos, faltan argumentos
        ///     requeridos o si ocurre un error en una de las operaciones.
        /// </param>
        public static void AutoRun(this CmdLineParser args, bool exitIfInvalidArgs)
        {
            if (args.Invalid.Any())
            {
                foreach (var j in args.Invalid)
{'fraction_non_alphanumeric': 0.10018270401948842, 'fraction_numerical': 0.004263093788063338, 'mean_word_length': 1.8989408649602824, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, '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': '5394238', 'n_tokens_mistral': 1783, 'n_tokens_neox': 1733, 'n_words': 606}