Ejemplo n.º 1
0
        /// <summary>
        /// Executes this action.
        /// </summary>
        /// <param name="pkgmgr">package manager instance</param>
        public void Execute(IPackageManager pkgmgr)
        {
            AbstractTree tree = LocalRepository.Read();
            List<IPackage> results = tree.Search(_atom, _options.exact);

            Console.WriteLine("\n[ Packages found: {0} ]", results.Count);

            if (results.Count > 0) {
                foreach (IPackage p in results) {
                    bool fmasked = false;

                    IDistribution latest = p.LatestUnmasked;
                    if (latest == null) {
                        latest = p.LatestAvailable;
                        fmasked = true;
                    }

                    PackageVersion iv = pkgmgr.QueryInstalledVersion(latest.Atom);
                    string ivstr = iv != null ? iv.ToString() : "[ Not Installed ]";

                    StringBuilder sizesb = new StringBuilder(11);
                    Win32.StrFormatByteSize(latest.TotalSize, sizesb, sizesb.Capacity);

                    Console.Write("\n");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("*");
                    Console.ResetColor();
                    Console.Write("  {0}", p.FullName);

                    if (fmasked) {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("  [ Masked ]\n");
                        Console.ResetColor();
                    } else
                        Console.Write("\n");

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("      Latest version available:");
                    Console.ResetColor();
                    Console.Write(" {0}\n", latest.Version.ToString());

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("      Latest version installed:");
                    Console.ResetColor();
                    Console.Write(" {0}\n", ivstr);

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("      Size of files:");
                    Console.ResetColor();
                    Console.Write(" {0}\n", sizesb);

                    if (!String.IsNullOrEmpty(p.Homepage)) {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("      Homepage:");
                        Console.ResetColor();
                        Console.Write(" {0}\n", p.Homepage);
                    }

                    if (!String.IsNullOrEmpty(p.Description)) {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("      Description:");
                        Console.ResetColor();
                        Console.Write(" {0}\n", p.Description);
                    }

                    if (!String.IsNullOrEmpty(p.License)) {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("      License:");
                        Console.ResetColor();
                        Console.Write(" {0}\n", p.License);
                    }
                }
            }

            Console.Write("\n");
        }