Exemple #1
0
        private static bool TryParseCommand(string[] args, ref int index, out CreateCommand func)
        {
            func = null;

            if (index >= args.Length)
            {
                Console.WriteLine("Need a command to run");
                return(false);
            }

            var name = args[index];

            switch (name)
            {
            case "verify":
                func = (c, s, g) => new VerifyCommand(c, s, g);
                break;

            case "view":
                func = (c, s, g) => new ViewCommand(c, s);
                break;

            case "consumes":
                func = (c, s, g) => new ConsumesCommand(RepoData.Create(c, s));
                break;

            case "change":
                func = (c, s, g) => new ChangeCommand(RepoData.Create(c, s), g);
                break;

            case "produces":
                func = (c, s, g) => new ProducesCommand(c, s);
                break;

            default:
                Console.Write($"Command {name} is not recognized");
                return(false);
            }

            index++;
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Verify the packages listed in project.json are well formed.  Packages should all either have the same version or
        /// be explicitly fixed in the config file.
        /// </summary>
        private bool VerifyProjectJsonContents(TextWriter writer, out RepoData repoData)
        {
            writer.WriteLine($"Verifying project.json contents");

            repoData = RepoData.Create(_repoConfig, _sourcesPath, out var conflicts);
            if (conflicts?.Count > 0)
            {
                foreach (var conflict in conflicts)
                {
                    writer.WriteLine($"Error! Package {conflict.PackageName} has different versions:");
                    writer.WriteLine($"\t{conflict.Original.FileName} at {conflict.Original.NuGetPackage.Version}");
                    writer.WriteLine($"\t{conflict.Conflict.FileName} at {conflict.Conflict.NuGetPackage.Version}");
                    writer.WriteLine($"The versions must be the same or one must be explicitly listed as fixed in RepoData.json");
                }

                return(false);
            }

            return(true);
        }