<commit_before>﻿// <copyright file="AddDependenciesAction.cs" company="<NAME>">
//  Opus
// </copyright>
// <summary>Opus main application.</summary>
// <author><NAME></author>

[assembly: Opus.Core.RegisterAction(typeof(Opus.AddDependenciesAction))]

namespace Opus
{
    [Core.TriggerAction]
    internal class AddDependenciesAction : Core.IActionWithArguments
    {
        public string CommandLineSwitch
        {
            get
            {
                return "-adddependencies";
            }
        }

        public string Description
        {
            get
            {
                return "Add dependent packages";
            }
        }

        public void AssignArguments(string arguments)
        {
            this.PackagesAndVersions = new Opus.Core.StringArray();
            this.PackagesAndVersions.AddRange(arguments.Split(';'));
        }

        private Core.StringArray PackagesAndVersions
        {
            get;
            set;
        }

        public bool Execute()
        {
            bool isComplete;
            Core.PackageIdentifier mainPackageId = Core.PackageUtilities.IsPackageDirectory(Core.State.WorkingDirectory, out isComplete);
            if (null == mainPackageId)
            {
                throw new Core.Exception(System.String.Format("Working directory, '{0}', is not a package", Core.State.WorkingDirectory), false);
            }
            if (!isComplete)
            {
                throw new Core.Exception(System.String.Format("Working directory, '{0}', is not a valid package", Core.State.WorkingDirectory), false);
            }

            Core.PackageDefinitionFile xmlFile = new Core.PackageDefinitionFile(mainPackageId.DefinitionPathName, true);
            if (isComplete)
            {
                xmlFile.Read();
            }

            foreach (string packageAndVersion in this.PackagesAndVersions)
            {
                string[] packageNameAndVersion = packageAndVersion.Split('-');
                if (packageNameAndVersion.Length != 2)
                {
                    throw new Core.Exception(System.String.Format("Ill-formed package name-version pair, '{0}'", packageAndVersion), false);
                }

                Core.PackageIdentifier id = new Opus.Core.PackageIdentifier(packageNameAndVersion[0], packageNameAndVersion[1]);
                xmlFile.AddRequiredPackage(id);
            }

            xmlFile.Write();

            return true;
        }
    }
}<commit_msg>[xml] Change -adddependencies to -adddependency as only one at a time makes more sense now.<commit_after>﻿// <copyright file="AddDependenciesAction.cs" company="<NAME>">
//  Opus
// </copyright>
// <summary>Opus main application.</summary>
// <author><NAME></author>

[assembly: Opus.Core.RegisterAction(typeof(Opus.AddDependenciesAction))]

namespace Opus
{
    [Core.TriggerAction]
    internal class AddDependenciesAction : Core.IActionWithArguments
    {
        public string CommandLineSwitch
        {
            get
            {
                return "-adddependency";
            }
        }

        public string Description
        {
            get
            {
                return "Add a dependent package";
            }
        }

        public void AssignArguments(string arguments)
        {
            this.PackageAndVersion = arguments;
        }

        private string PackageAndVersion
        {
            get;
            set;
        }

        public bool Execute()
        {
            bool isComplete;
            Core.PackageIdentifier mainPackageId = Core.PackageUtilities.IsPackageDirectory(Core.State.WorkingDirectory, out isComplete);
            if (null == mainPackageId)
            {
                throw new Core.Exception(System.String.Format("Working directory, '{0}', is not a package", Core.State.WorkingDirectory), false);
            }
            if (!isComplete)
            {
                throw new Core.Exception(System.String.Format("Working directory, '{0}', is not a valid package", Core.State.WorkingDirectory), false);
            }

            Core.PackageDefinitionFile xmlFile = new Core.PackageDefinitionFile(mainPackageId.DefinitionPathName, true);
            if (isComplete)
            {
                xmlFile.Read();
            }

            string[] packageNameAndVersion = this.PackageAndVersion.Split('-');
            if (packageNameAndVersion.Length != 2)
            {
                throw new Core.Exception(System.String.Format("Ill-formed package name-version pair, '{0}'", this.PackageAndVersion), false);
            }

            Core.PackageIdentifier id = new Opus.Core.PackageIdentifier(packageNameAndVersion[0], packageNameAndVersion[1]);
            xmlFile.AddRequiredPackage(id);

            xmlFile.Write();

            return true;
        }
    }
}
{'fraction_non_alphanumeric': 0.09542822918746256, 'fraction_numerical': 0.002395687762028349, 'mean_word_length': 1.6978998384491115, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, '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': '2999382', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1183, 'n_words': 250}