\r
private PackageListsManager pkgListMan;\r
\r
+ /// <summary>\r
+ /// サイレントインストールをするか否か\r
+ /// </summary>\r
+ private bool silent = false;\r
+ \r
public MainClass()\r
{\r
downloader = new Downloader();\r
downloader.DownloadEventRaised += new EventHandler<DownloadEventArgs>(dl.OnDownload);\r
\r
pkgListMan = new PackageListsManager();\r
+ pkgListMan.LoadPackageLists();\r
}\r
\r
public void Update()\r
public void update(bool downloadPackageListFlag)\r
{\r
NaGet.SubCommands.NaGetUpdate tasks = new NaGet.SubCommands.NaGetUpdate(pkgListMan, downloadPackageListFlag);\r
- tasks.Downloader = this.downloader;\r
tasks.TaskSetRaised += delegate(object sender, NaGetTaskSetEventArgs e) { \r
switch (e.Type) {\r
// case NaGetTaskSetEventType.COMPLETED_TASKSET\r
break;\r
}\r
};\r
+ DownloadListener dl = new DownloadListener();\r
+ tasks.Downloader.DownloadEventRaised += dl.OnDownload;\r
\r
tasks.Run();\r
}\r
\r
- public void Upgrade()\r
+ public void CheckUpgrade()\r
{\r
PackageList<Package> packageList = pkgListMan.AvailablePkgList;\r
\r
VersionComparetor verComp = new VersionComparetor();\r
\r
- foreach (InstalledPackage pkg in pkgListMan.InstalledPkgList.Packages) {\r
+ foreach (InstalledPackage pkg in pkgListMan.InstalledPkgList) {\r
Package avaiablePkg = packageList.GetPackageForName(pkg.Name);\r
\r
if (avaiablePkg != null) {\r
if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 &&\r
pkgListMan.InstalledPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) {\r
- Console.ForegroundColor = ConsoleColor.Green;\r
+ \r
+ Console.WriteLine("{0} ({1}) => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
}\r
- \r
- Console.WriteLine("{0} ({1}) => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
- Console.ResetColor();\r
}\r
}\r
- foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList.Packages) {\r
+ foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList) {\r
Package avaiablePkg = packageList.GetPackageForName(pkg.Name);\r
\r
if (avaiablePkg != null) {\r
if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 &&\r
pkgListMan.SystemInstalledPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) {\r
- Console.ForegroundColor = ConsoleColor.Green;\r
+ \r
+ Console.WriteLine("{0} ({1})@sys => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
}\r
- \r
- Console.WriteLine("{0} ({1})@sys => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
- Console.ResetColor();\r
}\r
}\r
}\r
foreach (Package pkg in allPkgs.GetPackagesForName(packagename)) {\r
Console.WriteLine("Package: {0}", pkg.Name);\r
Console.WriteLine("Version: {0}", pkg.Version);\r
+ Console.WriteLine("Summary: {0}", pkg.Summary);\r
if (pkg.Url != null) Console.WriteLine("Website: {0}", pkg.Url.Href);\r
if (pkg.Tags != null) Console.WriteLine("Tag: {0}", pkg.Tags.ToLower());\r
Console.WriteLine("Type: {0}", pkg.Type);\r
if (pkg.License != null) Console.WriteLine("License: {0}", pkg.License);\r
if (pkg is InstalledPackage) Console.WriteLine("State: Installed");\r
+ Console.WriteLine("Repository: {0}", pkg.PackageListName);\r
\r
if (pkg.Description != null) {\r
Console.WriteLine("Description:");\r
for (int i = 0; i < installations.Length; i++) {\r
installations[i] = new Installation((Package) downloadList[i]);\r
\r
+ installations[i].Silent = silent; // サイレントインストールのフラグの設定\r
+ \r
if (! installations[i].IsInstallablePackage()) {\r
Console.WriteLine("E: Can not install package {0} to your PC.", installations[i].ToString());\r
Environment.Exit(1);\r
}\r
}\r
\r
+ Installation[] depInstallations;\r
+ {\r
+ Installation[] resolved;\r
+ DependeciesResolver.ResolveInstallations(installations, pkgListMan, out resolved, out depInstallations);\r
+ installations = resolved;\r
+ }\r
+ \r
Console.WriteLine("The following packages will be downloaded:");\r
Console.WriteLine(" {0}", Installation.ToString(installations));\r
if (AllGet.Util.Confirm("Do you want to continue [Y/n]?", true) == false) {\r
}\r
\r
NaGet.SubCommands.NaGetInstall tasks = new NaGet.SubCommands.NaGetInstall(pkgListMan, installations);\r
- tasks.Downloader = this.downloader;\r
+ tasks.TaskQueryRaised += delegate(object sender, NaGetTaskQueryArgs e) {\r
+ char result = '\u0000';\r
+ if (e.SelectionFlag == (NaGetTaskQueryResult.CONTINUE | NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+ result = AllGet.Util.Query(e.Message + " [y/R/n]?", "yrn", 'r');\r
+ } else if (e.SelectionFlag == (NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+ result = AllGet.Util.Query(e.Message + " [R/n]?", "rn", 'r');\r
+ } else if (e.SelectionFlag == NaGetTaskQueryResult.CONTINUE) {\r
+ result = AllGet.Util.Query(e.Message + " [Y]?", "y", 'y');\r
+ } else {\r
+ result = AllGet.Util.Query(e.Message + " [Y/n]?", "yn", 'y');\r
+ }\r
+ \r
+ switch (result) {\r
+ case 'y':\r
+ return NaGetTaskQueryResult.CONTINUE;\r
+ case 'n':\r
+ return NaGetTaskQueryResult.CANCEL;\r
+ case 'r':\r
+ return NaGetTaskQueryResult.RETRY;\r
+ default:\r
+ return NaGetTaskQueryResult.CANCELED_AUTOMATICALLY;\r
+ }\r
+ };\r
tasks.TaskSetRaised += delegate(object sender, NaGetTaskSetEventArgs e) { \r
switch (e.Type) {\r
// case NaGetTaskSetEventType.COMPLETED_TASKSET\r
break;\r
}\r
};\r
+ DownloadListener dl = new DownloadListener();\r
+ tasks.Downloader.DownloadEventRaised += dl.OnDownload;\r
\r
tasks.Run();\r
}\r
Console.WriteLine("\t{0} search|show pkg1 [pkg2 ...]", executeFileName);\r
Console.WriteLine("\t{0} cleancache [pkg ...]", executeFileName);\r
Console.WriteLine("\t{0} download pkg1 [pkg2 ...]", executeFileName);\r
- Console.WriteLine("\t{0} install|uninstall pkg1 [pkg2 ...]", executeFileName);\r
+ Console.WriteLine("\t{0} [--quiet] install|uninstall pkg1 [pkg2 ...]", executeFileName);\r
Console.WriteLine();\r
Console.WriteLine("{0} is a simple command line interface for downloading and "+\r
"installing packages. The most frequently used commands are update "+\r
Console.WriteLine("Commands:");\r
Console.WriteLine(" update - Retrieve new lists of packages");\r
Console.WriteLine(" localupdate - Update installed-soft-list only");\r
+ Console.WriteLine(" checkupgrade - Show upgraded-soft list");\r
Console.WriteLine(" search - Search the package list for not a regex pattern");\r
Console.WriteLine(" show - Show package detail");\r
Console.WriteLine(" cleancache - Clear cached archived file(s)");\r
\r
public void FooBar()\r
{\r
- foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList.Packages) {\r
+ foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList) {\r
Console.WriteLine("{0} : {1}", pkg.Name, pkg.UninstallInfo.UninstallString);\r
}\r
}\r
}\r
}\r
\r
+ public void Moo()\r
+ {\r
+ // TODO スーパー牛さんパワー化\r
+ \r
+ string executeFileName = System.AppDomain.CurrentDomain.FriendlyName;\r
+ Console.WriteLine("誰か {0} をスーパー牛さんパワー化してくれ", executeFileName);\r
+ }\r
+ \r
+ [STAThread]\r
public static void Main(string[] args)\r
{\r
// アーカイブSYSTEM32をパスに足す\r
\r
if (args.Length == 0) {\r
mc.Help();\r
- } else if (args[0] == "update") {\r
- if (args.Length != 1) {\r
- Console.WriteLine("E: The update command takes no arguments");\r
- Environment.Exit(1);\r
- }\r
- mc.Update();\r
- } else if (args[0] == "localupdate") {\r
- if (args.Length != 1) {\r
- Console.WriteLine("E: The update command takes no arguments");\r
- Environment.Exit(1);\r
- }\r
- mc.LocalUpdate();\r
- } else if (args[0] == "search") {\r
- if (args.Length <= 1) {\r
- Console.WriteLine("E: You must give exactly one pattern");\r
- Environment.Exit(1);\r
- }\r
- \r
- mc.Search(string.Join(" ", args, 1, args.Length - 1));\r
- } else if (args[0] == "show") {\r
- if (args.Length <= 1) {\r
- Console.WriteLine("E: You must give exactly one pattern");\r
- Environment.Exit(1);\r
- }\r
- \r
- for (int i = 1; i < args.Length; i++) {\r
- mc.Show(args[i]);\r
- }\r
- } else if (args[0] == "download") {\r
- if (args.Length <= 1) {\r
- Console.WriteLine("E: Invalid operation download");\r
- Environment.Exit(1);\r
- }\r
- \r
- string[] packages = new string[args.Length - 1];\r
- Array.Copy(args, 1, packages, 0, packages.Length);\r
\r
- mc.Download(packages);\r
- } else if (args[0] == "install") {\r
- if (args.Length <= 1) {\r
- Console.WriteLine("E: Invalid operation install");\r
+ Environment.Exit(1);\r
+ } else {\r
+ try {\r
+ NaGet.ArgParser argParser = new NaGet.ArgParser();\r
+ argParser["quiet"] = false;\r
+ args = argParser.Parse(args);\r
+ mc.silent = (bool) argParser["quiet"];\r
+ } catch (ApplicationException e) {\r
+ Console.WriteLine(e.Message);\r
Environment.Exit(1);\r
}\r
- \r
- string[] packages = new string[args.Length - 1];\r
- Array.Copy(args, 1, packages, 0, packages.Length);\r
- \r
- mc.Install(packages);\r
- } else if (args[0] == "upgrade") {\r
- mc.Upgrade();\r
- } else if (args[0] == "remove") {\r
- if (args.Length <= 1) {\r
- Console.WriteLine("E: Invalid operation remove");\r
+ }\r
+ \r
+ // 引数ごとに操作を決定\r
+ switch (args[0])\r
+ {\r
+ case "update":\r
+ if (args.Length != 1) {\r
+ Console.WriteLine("E: The update command takes no arguments");\r
+ Environment.Exit(1);\r
+ }\r
+ mc.Update();\r
+ break;\r
+ case "localupate":\r
+ if (args.Length != 1) {\r
+ Console.WriteLine("E: The update command takes no arguments");\r
+ Environment.Exit(1);\r
+ }\r
+ mc.LocalUpdate();\r
+ break;\r
+ case "search":\r
+ if (args.Length <= 1) {\r
+ Console.WriteLine("E: You must give exactly one pattern");\r
+ Environment.Exit(1);\r
+ }\r
+ \r
+ mc.Search(string.Join(" ", args, 1, args.Length - 1));\r
+ break;\r
+ case "show":\r
+ if (args.Length <= 1) {\r
+ Console.WriteLine("E: You must give exactly one pattern");\r
+ Environment.Exit(1);\r
+ }\r
+ \r
+ for (int i = 1; i < args.Length; i++) {\r
+ mc.Show(args[i]);\r
+ }\r
+ break;\r
+ case "download":\r
+ if (args.Length <= 1) {\r
+ Console.WriteLine("E: Invalid operation download");\r
+ Environment.Exit(1);\r
+ } else {\r
+ string[] packages = new string[args.Length - 1];\r
+ Array.Copy(args, 1, packages, 0, packages.Length);\r
+ \r
+ mc.Download(packages);\r
+ }\r
+ break;\r
+ case "install":\r
+ if (args.Length <= 1) {\r
+ Console.WriteLine("E: Invalid operation install");\r
+ Environment.Exit(1);\r
+ } else {\r
+ string[] packages = new string[args.Length - 1];\r
+ Array.Copy(args, 1, packages, 0, packages.Length);\r
+ \r
+ mc.Install(packages);\r
+ }\r
+ break;\r
+ case "checkupgrade":\r
+ mc.CheckUpgrade();\r
+ break;\r
+ case "remove":\r
+ if (args.Length <= 1) {\r
+ Console.WriteLine("E: Invalid operation remove");\r
+ Environment.Exit(1);\r
+ } else {\r
+ string[] packages = new string[args.Length - 1];\r
+ Array.Copy(args, 1, packages, 0, packages.Length);\r
+ \r
+ mc.Remove(packages);\r
+ }\r
+ break;\r
+ case "cleancache":\r
+ {\r
+ string[] packages = new string[args.Length - 1];\r
+ Array.Copy(args, 1, packages, 0, packages.Length);\r
+ \r
+ mc.CleanCache(packages);\r
+ }\r
+ break;\r
+ case "foobar":\r
+ mc.FooBar();\r
+ break;\r
+ case "hoge":\r
+ mc.Hoge();\r
+ break;\r
+ case "moo":\r
+ mc.Moo();\r
+ break;\r
+ default:\r
+ mc.Help();\r
+ \r
Environment.Exit(1);\r
- }\r
- \r
- string[] packages = new string[args.Length - 1];\r
- Array.Copy(args, 1, packages, 0, packages.Length);\r
- \r
- mc.Remove(packages);\r
- } else if (args[0] == "cleancache") {\r
- string[] packages = new string[args.Length - 1];\r
- Array.Copy(args, 1, packages, 0, packages.Length);\r
- \r
- mc.CleanCache(packages);\r
- } else if (args[0] == "foobar") {\r
- mc.FooBar();\r
- } else if (args[0] == "hoge") {\r
- mc.Hoge();\r
- } else {\r
- mc.Help();\r
- \r
- Environment.Exit(1);\r
+ break;\r
}\r
}\r
}\r