<commit_before>﻿using System;

using Kirkin.CommandLine;

using NUnit.Framework;

namespace Kirkin.Tests.CommandLine
{
    public class CommandLineTests
    {
        [Test]
        public void BasicCommandLineParsing()
        {
            CommandLineParser parser = new CommandLineParser();
            Func<string, bool> ParseBoolean = value => string.IsNullOrEmpty(value) || Convert.ToBoolean(value);
            string subscription = null;
            bool validate = false;

            parser.DefineCommand("sync", sync =>
            {
                Func<string> subscriptionOption = sync.DefineOption("subscription", null);
                Func<bool> validateOption = sync.DefineOption("validate", "v", ParseBoolean);

                return () =>
                {
                    subscription = subscriptionOption();
                    validate = validateOption();
                };
            });

            ICommand command = parser.Parse("sync --subscription main /VALIDATE TRUE".Split(' '));

            command.Execute();

            Assert.AreEqual("main", subscription);
            Assert.True(validate);

            //Command sync = new Command("sync");
            //bool verify = false;

            //sync.DefineOption("v", "verify", ref verify);
            //sync.DefineParameter()

            //sync.Invoked += () =>
            //{
            //    if (verify)
            //    {

            //    }
            //    else
            //    {

            //    }
            //};<commit_msg>CommandLineTests: document bug when reparsing<commit_after>﻿using System;

using Kirkin.CommandLine;

using NUnit.Framework;

namespace Kirkin.Tests.CommandLine
{
    public class CommandLineTests
    {
        [Test]
        public void BasicCommandLineParsing()
        {
            CommandLineParser parser = new CommandLineParser();
            Func<string, bool> ParseBoolean = value => string.IsNullOrEmpty(value) || Convert.ToBoolean(value);
            string subscription = null;
            bool validate = false;

            parser.DefineCommand("sync", sync =>
            {
                Func<string> subscriptionOption = sync.DefineOption("subscription", null);
                Func<bool> validateOption = sync.DefineOption("validate", "v", ParseBoolean);

                return () =>
                {
                    subscription = subscriptionOption();
                    validate = validateOption();
                };
            });

            ICommand command = parser.Parse("sync --subscription main /VALIDATE TRUE".Split(' '));

            Assert.Null(subscription);
            Assert.False(validate);

            command.Execute();

            Assert.AreEqual("main", subscription);
            Assert.True(validate);

            command = parser.Parse("sync --subscription extra".Split(' '));

            Assert.AreEqual("main", subscription);
            Assert.True(validate);

            validate = false; // Reset.

            command.Execute();

            Assert.AreEqual("extra", subscription);
            Assert.False(validate); // Bug.

            //Command sync = new Command("sync");
            //bool verify = false;

            //sync.DefineOption("v", "verify", ref verify);
            //sync.DefineParameter()

            //sync.Invoked += () =>
            //{
            //    if (verify)
            //    {

            //    }
            //    else
            //    {

            //    }
            //};
{'fraction_non_alphanumeric': 0.12023877202956225, 'fraction_numerical': 0.0, 'mean_word_length': 1.4851694915254237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '5155473', 'n_tokens_mistral': 851, 'n_tokens_neox': 806, 'n_words': 169}