Something went wrong. Try again.
A OS written in C# and COSMOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192using System;using System.Collections.Generic;using System.Linq;using System.Security.Cryptography.X509Certificates;using System.Text;using System.Threading.Tasks;
namespace openPrism.Shell.Utils{ public class Clear : Command { public Clear() : base("clear") { } public override void Execute(string[] args) { Console.Clear(); } } public class Color : Command { public Color() : base("color") { } public override void Execute(string[] args) { var before = Console.ForegroundColor; if (args.Length == 1) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("error: argument not provided: color"); Console.ForegroundColor = before; return; } else if (args[1].ToString().ToLower() == "reset") { Console.ResetColor(); return; }
Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Warning: Do not use this in daily life. This might mess up other colors."); Console.ForegroundColor = before;
string input = args[1].ToString().ToLower();
if (input == "black") Console.ForegroundColor = ConsoleColor.Black; else if (input == "darkblue") Console.ForegroundColor = ConsoleColor.DarkBlue; else if (input == "darkgreen") Console.ForegroundColor = ConsoleColor.DarkGreen; else if (input == "darkcyan") Console.ForegroundColor = ConsoleColor.DarkCyan; else if (input == "darkred") Console.ForegroundColor = ConsoleColor.DarkRed; else if (input == "darkmagenta") Console.ForegroundColor = ConsoleColor.DarkMagenta; else if (input == "darkyellow") Console.ForegroundColor = ConsoleColor.DarkYellow; else if (input == "gray") Console.ForegroundColor = ConsoleColor.Gray; else if (input == "darkgray") Console.ForegroundColor = ConsoleColor.DarkGray; else if (input == "blue") Console.ForegroundColor = ConsoleColor.Blue; else if (input == "green") Console.ForegroundColor = ConsoleColor.Green; else if (input == "cyan") Console.ForegroundColor = ConsoleColor.Cyan; else if (input == "red") Console.ForegroundColor = ConsoleColor.Red; else if (input == "magenta") Console.ForegroundColor = ConsoleColor.Magenta; else if (input == "yellow") Console.ForegroundColor = ConsoleColor.Yellow; else if (input == "white") Console.ForegroundColor = ConsoleColor.White; else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"error: color not found: {args[1].ToString()}"); Console.ForegroundColor = before; } } } public class Alias : Command { private CommandManager _manager; public Alias(CommandManager manager) : base("alias") { _manager = manager; } public override void Execute(string[] args) { if (args.Length < 3) { var before = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; if (args.Length == 1) { Console.WriteLine("error: argument not provided: name"); } else { Console.WriteLine("error: argument not provided: command"); } Console.ForegroundColor = before; Console.WriteLine($"usage: {args[0]} <name> <command>"); } string name = args[1].ToLower(); string command = args[2];
_manager.AddAlias(name, command); } }}