コード例 #1
0
 public static bool TryTokenize(string command, bool textArg, out CommandToken token)
 {
     if (textArg)
     {
         if (!command.Contains("\""))
         {
             token = new CommandToken {
                 Command = "error", Args = new string[0]
             };
             return(false);
         }
         token = TokenizeTextArgs(command);
         return(true);
     }
     token = Tokenize(command);
     return(true);
 }
コード例 #2
0
        public static void Parse(CommandToken token, TerminalGame game)
        {
            Console.WriteLine("Command: {0}", token.Command);
            switch (token.Command)
            {
            case "":
            {
                game.Terminal.Write("");
                break;
            }

            case "echo":
            {
                Echo.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "sudo":
            {
                game.Terminal.WriteLine("user is not in the sudoers file.  This incidient will be reported.");
                break;
            }

            case "man":
            {
                break;
            }

            case "ip":
            {
                Ip.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "ifconfig":
            case "ipconfig":
            {
                Ifconfig.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "pwd":
            {
                game.Terminal.WriteLine($"{World.World.GetInstance().Player.ConnectedComp.FileSystem.CurrentDir.Name}");
                break;
            }

            case "cls":
            case "clear":
            {
                game.Terminal.Clear();
                break;
            }

            case "help":
            {
                game.Terminal.WriteLine(Utils.Help.GetHelp());
                break;
            }

            case "reboot":
            {
                break;
            }

            case "shutdown":
            {
                break;
            }

            case "quit":
            case "exit":
            {
                break;
            }

            case "login":
            {
                break;
            }

            case "disconnect":
            case "dc":
            {
                Disconnect.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "connect":
            {
                Connect.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "rm":
            {
                Rm.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "rmdir":
            {
                break;
            }

            case "mkdir":
            {
                Mkdir.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "touch":
            {
                Touch.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "cat":
            {
                Cat.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "ls":
            case "dir":
            {
                Ls.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "cd":
            {
                Cd.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "save":
            {
                World.World.GetInstance().Save();
                game.Terminal.WriteLine("Game saved.");
                break;
            }

            case "nmap":
            {
                Nmap.GetInstance().Init(game, null, token.Args);
                break;
            }

            case "sshnuke":
            {
                Sshnuke.GetIsntance().Init(game, null, token.Args);
                break;
            }

            default:
            {
                game.Terminal.WriteLine(token.Command + " is not a recognized command");
                break;
            }
            }
        }