|
1 | 1 | usingSystem; |
2 | 2 | usingSystem.Collections.Generic; |
3 | 3 | usingSystem.Text; |
| 4 | +usingSystem.IO; |
4 | 5 | usingSys=Cosmos.System; |
5 | 6 |
|
6 | 7 | namespaceebOS |
7 | 8 | { |
8 | 9 | publicclassKernel:Sys.Kernel |
9 | 10 | { |
10 | | - |
11 | | -protectedoverridevoidBeforeRun() |
| 11 | +privateconststringver="1.0.0"; |
| 12 | +protectedoverridevoidBeforeRun() |
12 | 13 | { |
13 | 14 | Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back."); |
14 | 15 | } |
15 | 16 |
|
16 | 17 | protectedoverridevoidRun() |
17 | 18 | { |
18 | | -Console.Write("Input: "); |
19 | | -varinput=Console.ReadLine(); |
20 | | -Console.Write("Text typed: "); |
21 | | -Console.WriteLine(input); |
| 19 | +voidabout() |
| 20 | +{ |
| 21 | +Console.WriteLine("ebOS "+ver); |
| 22 | +} |
| 23 | +string[]getdir(stringpath) |
| 24 | +{ |
| 25 | +string[]dirs=Directory.GetFileSystemEntries(path); |
| 26 | +returndirs; |
| 27 | +} |
| 28 | +voidhelp() |
| 29 | +{ |
| 30 | +Console.WriteLine("ebOS "+ver); |
| 31 | +Console.WriteLine("\nsystem commands:\n"+ |
| 32 | +"shutdown - shut down\n"+ |
| 33 | +"reboot/restart - reboot the system\n"+ |
| 34 | +"\ninfo:\n"+ |
| 35 | +"about/ver - show version\n"+ |
| 36 | +"help - show this help message\n"+ |
| 37 | +"\nother:\n"+ |
| 38 | +"zen - show the zen of python"); |
| 39 | +//"hello - display greeting\n" + |
| 40 | +//"zen - display zen of python\n"); |
| 41 | +} |
| 42 | +Kernelprogram=newKernel(); |
| 43 | +Console.ForegroundColor=ConsoleColor.Green; |
| 44 | +Console.WriteLine(@" |
| 45 | + ## |
| 46 | + ## ### ##### |
| 47 | + ## ## ## ## ## |
| 48 | + ##### ###### ## ## ## |
| 49 | + ## ## ## ## ## ## ##### |
| 50 | + ####### ## ## ## ## ## |
| 51 | + ## ## ## ## ## ## ## |
| 52 | + ##### ###### ### ##### |
| 53 | +
|
| 54 | +"); |
| 55 | +Console.ForegroundColor=ConsoleColor.Blue; |
| 56 | +Console.Write(" "); |
| 57 | +about(); |
| 58 | +Console.ForegroundColor=ConsoleColor.White; |
| 59 | +while(true) |
| 60 | +{ |
| 61 | +Console.Write("0:> "); |
| 62 | +stringi=Console.ReadLine().ToLower(); |
| 63 | +string[]ilist=i.Split(' '); |
| 64 | +switch(ilist[0]) |
| 65 | +{ |
| 66 | +//system commands |
| 67 | +case"shutdown": |
| 68 | +//Cosmos.Sys.Deboot.ShutDown() |
| 69 | +Console.WriteLine("Shutting down..."); |
| 70 | +break; |
| 71 | +case"reboot": |
| 72 | +//Cosmos.Sys.Deboot.Reboot(); |
| 73 | +Console.WriteLine("Rebooting..."); |
| 74 | +break; |
| 75 | +case"restart": |
| 76 | +//Cosmos.Sys.Deboot.Reboot(); |
| 77 | +Console.WriteLine("Rebooting..."); |
| 78 | +break; |
| 79 | +//info |
| 80 | +case"about": |
| 81 | +about(); |
| 82 | +break; |
| 83 | +case"ver": |
| 84 | +about(); |
| 85 | +break; |
| 86 | +case"help": |
| 87 | +help(); |
| 88 | +break; |
| 89 | +case"dir": |
| 90 | +if(!(ilist.Length>1)) |
| 91 | +{ |
| 92 | +getdir(ilist[1]); |
| 93 | + |
| 94 | +} |
| 95 | +else |
| 96 | +{ |
| 97 | +getdir(Directory.GetCurrentDirectory()); |
| 98 | + |
| 99 | +} |
| 100 | +about(); |
| 101 | +break; |
| 102 | +//no reason |
| 103 | +case"hello": |
| 104 | +Console.WriteLine("Hello World"); |
| 105 | +break; |
| 106 | +case"zen": |
| 107 | +Console.WriteLine("The Zen of Python, by Tim Peters\n\nBeautiful is better than ugly.\nExplicit is better than implicit.\nSimple is better than complex.\nComplex is better than complicated.\nFlat is better than nested.\nSparse is better than dense.\nReadability counts.\nSpecial cases aren't special enough to break the rules.\nAlthough practicality beats purity.\nErrors should never pass silently.\nUnless explicitly silenced.\nIn the face of ambiguity, refuse the temptation to guess.\nThere should be one-- and preferably only one --obvious way to do it.\nAlthough that way may not be obvious at first unless you're Dutch.\nNow is better than never.\nAlthough never is often better than *right* now.\nIf the implementation is hard to explain, it's a bad idea.\nIf the implementation is easy to explain, it may be a good idea.\nNamespaces are one honking great idea -- let's do more of those!"); |
| 108 | +break; |
| 109 | + |
| 110 | +//default |
| 111 | +default: |
| 112 | +Console.WriteLine(i+" is not a command!"); |
| 113 | +break; |
| 114 | + |
| 115 | +} |
| 116 | +} |
22 | 117 | } |
23 | | -} |
| 118 | + |
| 119 | + |
| 120 | +} |
24 | 121 | } |