public CommandProcessor(SystemUser currentUser, SystemInfo info, ref FileSystem fs) { _currentUser = currentUser; CurrentLocation = currentUser.HomeDir; _info = info; /* * COMMANDS HANDLERS INITIALIZATION */ var listFiles = new ListFiles(ref fs); var changeDir = new ChangeDirectory(ref fs); // Update location changeDir.Navigated += delegate(string location) { CurrentLocation = location; }; // Set current location to current user home directory changeDir.NavigatedToHome += delegate(string location) { CurrentLocation = _currentUser.HomeDir; }; _commands = new List <Command> { changeDir, listFiles, new CreateFile(ref fs), new CreateDirectory(ref fs), new RemoveFile(ref fs), new Echo(ref fs), new ReadFile(ref fs), }; }
public static IDisposable ChangeTo(string directory) { if (string.IsNullOrWhiteSpace(directory)) { return new DoNothing(); } var disposable = new ChangeDirectory(Environment.CurrentDirectory); Environment.CurrentDirectory = directory; return disposable; }
private void Update() { if (TrainDoors.areDoorsOpen == true) { SetDestination(); } if (ChangeDirectory.destinationReached(_navMeshAgent)) { FileUtil.MoveFileOrDirectory("male2Platform", "GrandSt/Train_Animated/People"); //transform.Find("male2Platform").gameObject.GetComponent<>().enabled = false; } }
public void RunCommand(List <string> cmdList) { string cmdFirst = cmdList[0]; cmdList.RemoveAt(0); switch (cmdFirst) { case "help": Help.OnJoin(cmdList); break; case "setting": Setting.SettingSwitch(cmdList); break; case "cd": ChangeDirectory.ChangeDirectorySwitch(cmdList); break; case "ls": ListOfElement.ListOfElementSwitch(cmdList); break; default: /* */ if (cmdFirst == string.Empty) { Console.WriteLine("Write a command."); } else { ICommand command = PluginManager.commands.FirstOrDefault(c => c.Cmd == cmdFirst); if (command != null) { command.Execute(cmdList); } else { Console.WriteLine($"Command \"{cmdFirst}\" not found."); } } break; } }
private static void Main(string[] args) { Console.WriteLine("Squirrely Core CMD (C) 2018 MrSquirrely.net"); for (; true;) { START: Console.WriteLine(); if (!Reference.inDirectory) { Console.Write(">>"); } else { Console.Write($"{Reference.currentDirectory} >>"); } Reference.commandWrote = Console.ReadLine(); Reference.command.Clear(); foreach (string word in Reference.commandWrote.Split(new char[] { ' ' })) { Reference.command.Add(word); } switch (Reference.command[0].ToLower()) { case "ping": Console.WriteLine(); ConsolePing.Ping(); break; case "cd": Console.WriteLine(); ChangeDirectory.CD(); break; case "dir": Console.WriteLine(); ListDirectory.DIR(); break; case "color": Console.WriteLine(); Color.ChangeColor(); break; case "date": Console.WriteLine(); Console.WriteLine(DateTime.Now); break; case "echo": Console.WriteLine(); string echo = ""; for (int i = 1; i < Reference.command.Count; i++) { echo = $"{echo}{Reference.command[i]} "; } Console.WriteLine(echo); break; case "cls": case "clear": Console.Clear(); break; case "?": case "help": Console.WriteLine(); Help.ShowHelp(); break; case "exit": Environment.Exit(0); break; default: Console.WriteLine(); Console.WriteLine("Unknow command, Type in '?' in to see a list of possible commands"); break; } goto START; } }