OSDN Git Service

AppliStation-All,インストール処理を新方式(NaGetInstall2)に変更。
[applistation/AppliStation.git] / all-get / Main.cs
1 // project created on 2007/09/08 at 20:20\r
2 using System;\r
3 using System.IO;\r
4 using System.Collections.Generic;\r
5 using NaGet.Net;\r
6 using NaGet.Packages;\r
7 using NaGet.Packages.Install;\r
8 using NaGet.SubCommands;\r
9 using NaGet.Tasks;\r
10 \r
11 namespace AllGet\r
12 {\r
13 \r
14         class DownloadListener\r
15         {\r
16                 private string line = null;\r
17                 \r
18                 /// <summary>\r
19                 /// lineのコンソール上における長さ\r
20                 /// </summary>\r
21                 private int lineWidth = 0;\r
22         \r
23                 public void OnDownload(object sender, DownloadEventArgs a) {\r
24                         if (line != null) {\r
25                                 lock (line) {\r
26                                         int newpos = (lineWidth <= 0)? 0 : Console.CursorLeft - lineWidth;\r
27                                         if (newpos < 0) newpos = 0;\r
28                                         \r
29                                         // 空白で埋める\r
30                                         Console.CursorLeft = newpos;\r
31                                         for (int i = 0; i < lineWidth && Console.CursorLeft < Console.BufferWidth; i++) {\r
32                                                 Console.Write(' ');\r
33                                         }\r
34                                         Console.CursorLeft = newpos;\r
35                                         \r
36                                         line = null; lineWidth = 0;\r
37                                 }\r
38                         }\r
39                         \r
40                         switch (a.DownloadTaskType) {\r
41                         case DownloadEventType.INITED:\r
42                                 line = "starting...";\r
43                                 break;\r
44                         case DownloadEventType.CONNECTED:\r
45                         case DownloadEventType.DOWNLOADING:\r
46                                 line = a.TaskMessage;\r
47                                 break;\r
48                         case DownloadEventType.COMPLETED:\r
49                                 //\r
50                                 line = null;\r
51                                 break;\r
52                         case DownloadEventType.ERROR:\r
53                                 Console.Write("interrupted! ERROR!");\r
54                                 line = null;\r
55                                 break;\r
56                         }\r
57                         \r
58                         if (line != null) {\r
59                                 int posOld = Console.CursorLeft;\r
60                                 Console.Write(line);\r
61                                 lineWidth = Console.CursorLeft - posOld;\r
62                         }\r
63                 }\r
64         }\r
65 \r
66         sealed class TaskSetEventHandlers\r
67         {\r
68                 public static void OnTaskSetEvent(object sender, TaskEventArgs e) { \r
69                         switch (e.Type) {\r
70 //                              case NaGetTaskSetEventType.COMPLETED_TASKSET\r
71 //                                      break;\r
72                                 case TaskEventType.COMPLETED:\r
73                                         Console.WriteLine("Done.");\r
74                                         break;\r
75                                 case TaskEventType.STARTED_SUBTASK:\r
76                                         Console.Write("  " + e.TaskMessage);\r
77                                         break;\r
78                                 case TaskEventType.COMPLETED_SUBTASK:\r
79                                         Console.WriteLine(" ... Done. [{0}%]", (int) e.ProgressPercent);\r
80                                         break;\r
81                                 case TaskEventType.INFO:\r
82                                         Console.WriteLine("  " + e.TaskMessage);\r
83                                         break;\r
84                                 case TaskEventType.ERROR:\r
85                                 case TaskEventType.WARNING:\r
86                                         Console.WriteLine("  [Error]" + e.TaskMessage);\r
87                                         break;\r
88                         }\r
89                 }\r
90                 \r
91                 public static void OnDownloadSubTaskEvent(object sender, TaskEventArgs e)\r
92                 {\r
93                         if (sender is NaGet.SubCommands.SubTask.DownloadSubTask) {\r
94                                 if (e.Type == TaskEventType.STARTED) {\r
95                                         Console.WriteLine();\r
96                                 }\r
97                                 \r
98                                 int origPosX = Console.CursorLeft;\r
99                                 for (int i = 0; i < Console.WindowWidth - 1; i++) {\r
100                                         Console.Write(' ');\r
101                                 }\r
102                                 Console.CursorLeft = origPosX;\r
103                                 \r
104                                 switch (e.Type) {\r
105                                         case TaskEventType.PING:\r
106                                                 {\r
107                                                         int origPos = Console.CursorLeft;\r
108                                                         Console.Write(e.TaskMessage);\r
109                                                         Console.CursorLeft = origPos;\r
110                                                 }\r
111                                                 break;\r
112                                         case TaskEventType.WARNING:\r
113                                         case TaskEventType.ERROR:\r
114                                                 Console.WriteLine("  [Error]" + e.TaskMessage);\r
115                                                 break;\r
116                                         default:\r
117                                                 Console.WriteLine(e.TaskMessage);\r
118                                                 break;\r
119                                 }\r
120                         }\r
121                 }\r
122                 \r
123                 public static NaGetTaskQueryResult OnTaskQueryEvent(object sender, NaGetTaskQueryArgs e)\r
124                 {\r
125                         char result = '\u0000';\r
126                         if (e.SelectionFlag == (NaGetTaskQueryResult.CONTINUE | NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
127                                 result = AllGet.Util.Query(e.Message + " [y/R/n]?", "yrn", 'r');\r
128                         } else if (e.SelectionFlag == (NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
129                                 result = AllGet.Util.Query(e.Message + " [R/n]?", "rn", 'r');\r
130                         } else if (e.SelectionFlag == NaGetTaskQueryResult.CONTINUE) {\r
131                                 result = AllGet.Util.Query(e.Message + " [Y]?", "y", 'y');\r
132                         } else {\r
133                                 result = AllGet.Util.Query(e.Message + " [Y/n]?", "yn", 'y');\r
134                         }\r
135                         \r
136                         switch (result) {\r
137                                 case 'y':\r
138                                         return NaGetTaskQueryResult.CONTINUE;\r
139                                 case 'n':\r
140                                         return NaGetTaskQueryResult.CANCEL;\r
141                                 case 'r':\r
142                                         return NaGetTaskQueryResult.RETRY;\r
143                                 default:\r
144                                         return NaGetTaskQueryResult.CANCELED_AUTOMATICALLY;\r
145                         }\r
146                 }\r
147         }\r
148         \r
149         \r
150         class MainClass\r
151         {\r
152                 private Downloader downloader;\r
153                 \r
154                 private PackageListsManager pkgListMan;\r
155                 \r
156                 /// <summary>\r
157                 /// サイレントインストールをするか否か\r
158                 /// </summary>\r
159                 private bool silent = false;\r
160                 \r
161                 public MainClass()\r
162                 {\r
163                         downloader = new Downloader();\r
164                         DownloadListener dl = new DownloadListener();\r
165                         downloader.DownloadEventRaised += new EventHandler<DownloadEventArgs>(dl.OnDownload);\r
166                         \r
167                         pkgListMan = new PackageListsManager();\r
168                         pkgListMan.LoadPackageLists();\r
169                 }\r
170                 \r
171                 public void Update()\r
172                 {\r
173                         update(true);\r
174                 }\r
175                 \r
176                 public void LocalUpdate()\r
177                 {\r
178                         update(false);\r
179                 }\r
180                 \r
181                 public void update(bool downloadPackageListFlag)\r
182                 {\r
183                         NaGet.SubCommands.NaGetUpdate2 tasks = new NaGet.SubCommands.NaGetUpdate2(pkgListMan, downloadPackageListFlag);\r
184                         tasks.TaskEventRaised += TaskSetEventHandlers.OnTaskSetEvent;\r
185                         tasks.SubTaskEventRaised += TaskSetEventHandlers.OnDownloadSubTaskEvent;\r
186                         \r
187                         tasks.Run();\r
188                 }\r
189                 \r
190                 public void CheckUpgrade()\r
191                 {\r
192                         foreach (Package pkg in UpgradeFinder.GetUpgradePackages(pkgListMan)) {\r
193                                 bool isSystem = false;\r
194                                 Package instPkg = null;\r
195                                 \r
196                                 instPkg = pkgListMan.SystemInstalledPkgList.GetPackageForName(pkg.Name);\r
197                                 if (instPkg != null) {\r
198                                         isSystem = true;\r
199                                 } else {\r
200                                         instPkg = pkgListMan.InstalledPkgList.GetPackageForName(pkg.Name);\r
201                                         if (instPkg != null) {\r
202                                                 isSystem = false;\r
203                                         } else {\r
204                                                 System.Diagnostics.Debug.Fail("internal error.");\r
205                                         }\r
206                                 }\r
207                                 \r
208                                 Console.WriteLine("{0} ({1}){3} => ({2})", pkg.Name, instPkg.Version, pkg.Version, (isSystem)? "@sys" : "");\r
209                         }\r
210                 }\r
211                 \r
212                 public void Search(string keys)\r
213                 {\r
214                         foreach(Package package in pkgListMan.AvailablePkgList.Search(keys)) {\r
215                                 Console.WriteLine("{0} ({1}) - {2}", package.Name, package.Version, package.Summary);\r
216                         }\r
217                         \r
218                         foreach(InstalledPackage package in pkgListMan.InstalledPkgList.Search(keys)) {\r
219                                 Console.WriteLine("{0} ({1})[@install] - {2}", package.Name, package.Version, package.Summary);\r
220                         }\r
221                         \r
222                         foreach(InstalledPackage package in pkgListMan.SystemInstalledPkgList.Search(keys)) {\r
223                                 Console.WriteLine("{0} ({1})[@sys] - {2}", package.Name, package.Version, package.Summary);\r
224                         }\r
225                 }\r
226                 \r
227                 public void Show(string packagename)\r
228                 {\r
229                         PackageList<Package> allPkgs = new PackageList<Package>();\r
230                         allPkgs.AddPackages(pkgListMan.GetAllPackages());\r
231                         \r
232                         foreach (Package pkg in allPkgs.GetPackagesForName(packagename)) {\r
233                                 Console.WriteLine("Package: {0}", pkg.Name);\r
234                                 Console.WriteLine("Version: {0}", pkg.Version);\r
235                                 Console.WriteLine("Summary: {0}", pkg.Summary);\r
236                                 if (pkg.Url != null) Console.WriteLine("Website: {0}", pkg.Url.Href);\r
237                                 if (pkg.Tags != null) Console.WriteLine("Tag: {0}", pkg.Tags.ToLower());\r
238                                 Console.WriteLine("Type: {0}", pkg.Type);\r
239                                 if (pkg.License != null) Console.WriteLine("License: {0}", pkg.License);\r
240                                 if (pkg is InstalledPackage) Console.WriteLine("State: Installed");\r
241                                 Console.WriteLine("Repository: {0}", pkg.PackageListName);\r
242                                 \r
243                                 if (pkg.Description != null) {\r
244                                         Console.WriteLine("Description:");\r
245                                         Console.WriteLine(pkg.Description);\r
246                                 }\r
247                                 Console.WriteLine();\r
248                         }\r
249                 }\r
250                 \r
251                 \r
252                 public void Download(string[] packagenames)\r
253                 {\r
254                         Installation[] installations = null;\r
255                         {\r
256                                 List<Package> downloadList = new List<Package>();\r
257                         \r
258                                 foreach(string packagename in packagenames) {\r
259                                         Package foundPackage = pkgListMan.AvailablePkgList.GetPackageForName(packagename);\r
260                                         if (foundPackage == null) {\r
261                                                 Console.WriteLine("E: Couldn't find package "+packagename);\r
262                                                 Environment.Exit(1);\r
263                                         }\r
264                                         if (! downloadList.Contains(foundPackage)) {\r
265                                                 downloadList.Add(foundPackage);\r
266                                         }\r
267                                 }\r
268                                 \r
269                                 installations = new Installation[downloadList.Count];\r
270                                 for (int i = 0; i < installations.Length; i++) {\r
271                                         installations[i] = new Installation(downloadList[i]);\r
272                                 }\r
273                         }\r
274                         \r
275                         Console.WriteLine("The following packages will be downloaded:");\r
276                         Console.WriteLine("  {0}", Installation.ToString(installations));\r
277                         if (AllGet.Util.Confirm("Do you want to continue [Y/n]?", true) == false) {\r
278                                 Console.WriteLine("Abort.");\r
279                                 Environment.Exit(0);\r
280                         }\r
281                         \r
282                         NaGet.SubCommands.NaGetDownloadToCache2 tasks = new NaGet.SubCommands.NaGetDownloadToCache2(pkgListMan, installations);\r
283                         tasks.TaskEventRaised += TaskSetEventHandlers.OnTaskSetEvent;\r
284                         tasks.SubTaskEventRaised += TaskSetEventHandlers.OnDownloadSubTaskEvent;\r
285                         tasks.TaskQueryRaised += TaskSetEventHandlers.OnTaskQueryEvent;\r
286                         \r
287                         tasks.Run();\r
288                 }\r
289                 \r
290                 public void Install(string[] packagenames)\r
291                 {\r
292                         if (! NaGet.Utils.IsAdministrators()) {\r
293                                 Console.WriteLine("W: you are not administrators!");\r
294                         }\r
295                         \r
296                         Installation[] installations = null;\r
297                         {\r
298                                 List<Package> downloadList = new List<Package>();\r
299                         \r
300                                 foreach(string packagename in packagenames) {\r
301                                         Package foundPackage = pkgListMan.AvailablePkgList.GetPackageForName(packagename);\r
302                                         if (foundPackage == null) {\r
303                                                 Console.WriteLine("E: Couldn't find package "+packagename);\r
304                                                 Environment.Exit(1);\r
305                                         }\r
306                                         if (! downloadList.Contains(foundPackage)) {\r
307                                                 downloadList.Add(foundPackage);\r
308                                         }\r
309                                 }\r
310                                 \r
311                                 installations = new Installation[downloadList.Count];\r
312                                 for (int i = 0; i < installations.Length; i++) {\r
313                                         installations[i] = new Installation(downloadList[i]);\r
314                                 }\r
315                         }\r
316                         \r
317                         Installation[] depInstallations;\r
318                         {\r
319                                 Installation[] resolved;\r
320                                 DependeciesResolver.ResolveInstallations(installations, pkgListMan, out resolved, out depInstallations);\r
321                                 installations = resolved;\r
322                         }\r
323                         \r
324                         Console.WriteLine("The following packages will be downloaded:");\r
325                         Console.WriteLine("  {0}", Installation.ToString(installations));\r
326                         if (AllGet.Util.Confirm("Do you want to continue [Y/n]?", true) == false) {\r
327                                 Console.WriteLine("Abort.");\r
328                                 Environment.Exit(0);\r
329                         }\r
330                         \r
331                         NaGet.SubCommands.NaGetInstall2 tasks = new NaGet.SubCommands.NaGetInstall2(pkgListMan, installations);\r
332                         tasks.TaskEventRaised += TaskSetEventHandlers.OnTaskSetEvent;\r
333                         tasks.SubTaskEventRaised += TaskSetEventHandlers.OnDownloadSubTaskEvent;\r
334                         tasks.TaskQueryRaised += TaskSetEventHandlers.OnTaskQueryEvent;\r
335                         \r
336                         tasks.Run();\r
337                 }\r
338                 \r
339                 public void Remove(string[] packagenames)\r
340                 {\r
341                         if (! NaGet.Utils.IsAdministrators()) {\r
342                                 Console.WriteLine("W: you are not administrators!");\r
343                         }\r
344                         \r
345                         this.LocalUpdate();\r
346                         \r
347                         PackageList<InstalledPackage> installedPkgList = new PackageList<InstalledPackage>();\r
348                         installedPkgList.AddPackages(pkgListMan.GetAllInstalledPackages());\r
349                         \r
350                         InstalledPackage[] insPkgs = new InstalledPackage[packagenames.Length];\r
351                         for (int i = 0; i < packagenames.Length; i++) {\r
352                                 insPkgs[i] = installedPkgList.GetPackageForName(packagenames[i]);\r
353                                 \r
354                                 if (insPkgs[i] == null) {\r
355                                         Console.WriteLine("E: could not found package " + packagenames[i]);\r
356                                         Environment.Exit(1);\r
357                                 }\r
358                         }\r
359                         \r
360 //                      if (AllGet.Util.Confirm("Do you want to continue [Y/n]?", true) == false) {\r
361 //                              Console.WriteLine("Abort.");\r
362 //                              Environment.Exit(0);\r
363 //                      }\r
364                         \r
365                         NaGet.SubCommands.NaGetUninstall2 tasks = new NaGet.SubCommands.NaGetUninstall2(pkgListMan, insPkgs);\r
366                         tasks.TaskEventRaised += TaskSetEventHandlers.OnTaskSetEvent;\r
367                         \r
368                         tasks.Run();\r
369                 }\r
370                 \r
371                 public void CleanCache(string[] packages)\r
372                 {\r
373                         if (! Directory.Exists(NaGet.Env.ArchiveFolderPath)) {\r
374                                 return; \r
375                         }\r
376                         \r
377                         int i = 0;\r
378                         if (packages.Length == 0) {\r
379                                 foreach (string folder in Directory.GetDirectories(NaGet.Env.ArchiveFolderPath)) {\r
380                                         Directory.Delete(folder, true);\r
381                                         i ++;\r
382                                 }\r
383                         } else {\r
384                                 foreach (string package in packages) {\r
385                                         foreach (string folder in Directory.GetDirectories(NaGet.Env.ArchiveFolderPath, package+"*", SearchOption.TopDirectoryOnly)) {\r
386                                                 Directory.Delete(folder, true);\r
387                                                 i ++;\r
388                                         }\r
389                                 }\r
390                         }\r
391                         if (i > 0) {\r
392                                 Console.WriteLine("... Done.");\r
393                         }\r
394                 }\r
395                 \r
396                 public void Help()\r
397                 {\r
398                         string executeFileName = System.AppDomain.CurrentDomain.FriendlyName;\r
399                         Console.Write("Usage:");\r
400                         \r
401                         Console.WriteLine("\t{0} update|localupdate", executeFileName);\r
402                         Console.WriteLine("\t{0} search|show pkg1 [pkg2 ...]", executeFileName);\r
403                         Console.WriteLine("\t{0} cleancache [pkg ...]", executeFileName);\r
404                         Console.WriteLine("\t{0} download pkg1 [pkg2 ...]", executeFileName);\r
405                         Console.WriteLine("\t{0} [--quiet] install|uninstall pkg1 [pkg2 ...]", executeFileName);\r
406                         Console.WriteLine();\r
407                         Console.WriteLine("{0} is a simple command line interface for downloading and "+\r
408                                           "installing packages. The most frequently used commands are update "+\r
409                                           "and install.", executeFileName);\r
410                         Console.WriteLine();\r
411                         Console.WriteLine("Commands:");\r
412                         Console.WriteLine("   update - Retrieve new lists of packages");\r
413                         Console.WriteLine("   localupdate - Update installed-soft-list only");\r
414                         Console.WriteLine("   checkupgrade - Show upgraded-soft list");\r
415                         Console.WriteLine("   search - Search the package list for not a regex pattern");\r
416                         Console.WriteLine("   show - Show package detail");\r
417                         Console.WriteLine("   cleancache - Clear cached archived file(s)");\r
418                         Console.WriteLine("   download - Download only - do NOT install or unpack archives");\r
419                         Console.WriteLine("   install - Install new packages");\r
420                         Console.WriteLine("   remove - Uninstall packages");\r
421                         Console.WriteLine();\r
422                 }\r
423                 \r
424                 public void FooBar()\r
425                 {\r
426                         foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList) {\r
427                                 Console.WriteLine("{0} : {1}", pkg.Name, pkg.UninstallInfo.UninstallString);\r
428                         }\r
429                 }\r
430                 \r
431                 public void Hoge()\r
432                 {\r
433                         foreach (UninstallInformation uInfo in RegistriedUninstallers.Uninstallers) {\r
434                                 if (! uInfo.IsOSPatch && ! uInfo.IsSystemComponent) {\r
435                                         Console.WriteLine("{0}", uInfo.DisplayName);\r
436                                 }\r
437                         }\r
438                 }\r
439                 \r
440                 public void Moo()\r
441                 {\r
442                         // TODO スーパー牛さんパワー化\r
443                         \r
444                         string executeFileName = System.AppDomain.CurrentDomain.FriendlyName;\r
445                         Console.WriteLine("誰か {0} をスーパー牛さんパワー化してくれ", executeFileName);\r
446                 }\r
447                 \r
448                 [STAThread]\r
449                 public static void Main(string[] args)\r
450                 {\r
451                         // アーカイブSYSTEM32をパスに足す\r
452                         NaGet.Utils.AddDirectoryToPath(NaGet.Env.ArchiveSystem32);\r
453                         \r
454                         MainClass mc = new MainClass();\r
455                         \r
456                         if (args.Length == 0) {\r
457                                 mc.Help();\r
458                                 \r
459                                 Environment.Exit(1);\r
460                         } else {\r
461                                 try {\r
462                                         NaGet.ArgParser argParser = new NaGet.ArgParser();\r
463                                         argParser["quiet"] = false;\r
464                                         args = argParser.Parse(args);\r
465                                         mc.silent = (bool) argParser["quiet"];\r
466                                 } catch (ApplicationException e) {\r
467                                         Console.WriteLine(e.Message);\r
468                                         Environment.Exit(1);\r
469                                 }\r
470                         }\r
471                         \r
472                         // 引数ごとに操作を決定\r
473                         switch (args[0])\r
474                         {\r
475                                 case "update":\r
476                                         if (args.Length != 1) {\r
477                                                 Console.WriteLine("E: The update command takes no arguments");\r
478                                                 Environment.Exit(1);\r
479                                         }\r
480                                         mc.Update();\r
481                                         break;\r
482                                 case "localupate":\r
483                                         if (args.Length != 1) {\r
484                                                 Console.WriteLine("E: The update command takes no arguments");\r
485                                                 Environment.Exit(1);\r
486                                         }\r
487                                         mc.LocalUpdate();\r
488                                         break;\r
489                                 case "search":\r
490                                         if (args.Length <= 1) {\r
491                                                 Console.WriteLine("E: You must give exactly one pattern");\r
492                                                 Environment.Exit(1);\r
493                                         }\r
494                                         \r
495                                         mc.Search(string.Join(" ", args, 1, args.Length - 1));\r
496                                         break;\r
497                                 case "show":\r
498                                         if (args.Length <= 1) {\r
499                                                 Console.WriteLine("E: You must give exactly one pattern");\r
500                                                 Environment.Exit(1);\r
501                                         }\r
502                                         \r
503                                         for (int i = 1; i < args.Length; i++) {\r
504                                                 mc.Show(args[i]);\r
505                                         }\r
506                                         break;\r
507                                 case "download":\r
508                                         if (args.Length <= 1) {\r
509                                                 Console.WriteLine("E: Invalid operation download");\r
510                                                 Environment.Exit(1);\r
511                                         } else {\r
512                                                 string[] packages = new string[args.Length - 1];\r
513                                                 Array.Copy(args, 1, packages, 0, packages.Length);\r
514                                                 \r
515                                                 mc.Download(packages);\r
516                                         }\r
517                                         break;\r
518                                 case "install":\r
519                                         if (args.Length <= 1) {\r
520                                                 Console.WriteLine("E: Invalid operation install");\r
521                                                 Environment.Exit(1);\r
522                                         } else {\r
523                                                 string[] packages = new string[args.Length - 1];\r
524                                                 Array.Copy(args, 1, packages, 0, packages.Length);\r
525                                                 \r
526                                                 mc.Install(packages);\r
527                                         }\r
528                                         break;\r
529                                 case "checkupgrade":\r
530                                         mc.CheckUpgrade();\r
531                                         break;\r
532                                 case "remove":\r
533                                         if (args.Length <= 1) {\r
534                                                 Console.WriteLine("E: Invalid operation remove");\r
535                                                 Environment.Exit(1);\r
536                                         } else {\r
537                                                 string[] packages = new string[args.Length - 1];\r
538                                                 Array.Copy(args, 1, packages, 0, packages.Length);\r
539                                                 \r
540                                                 mc.Remove(packages);\r
541                                         }\r
542                                         break;\r
543                                 case "cleancache":\r
544                                         {\r
545                                                 string[] packages = new string[args.Length - 1];\r
546                                                 Array.Copy(args, 1, packages, 0, packages.Length);\r
547                                                 \r
548                                                 mc.CleanCache(packages);\r
549                                         }\r
550                                         break;\r
551                                 case "foobar":\r
552                                         mc.FooBar();\r
553                                         break;\r
554                                 case "hoge":\r
555                                         mc.Hoge();\r
556                                         break;\r
557                                 case "moo":\r
558                                         mc.Moo();\r
559                                         break;\r
560                                 default:\r
561                                         mc.Help();\r
562                                         \r
563                                         Environment.Exit(1);\r
564                                         break;\r
565                         }\r
566                 }\r
567         }\r
568 }\r