How to do a working command line

Topics: Using Cosmos (Developing your own OS, projects, etc)
Oct 10, 2014 at 3:11 PM
Hi i can make a command console in cosmos where i can type in commands like help but then it just crashes and i can't type anything again, I can i fix this?
The code is below.

// Main entry point of the kernel
    public static void Init()
    {
        var xBoot = new Cosmos.Sys.Boot();
        xBoot.Execute();
        Console.WriteLine("------------------------------");
        Console.WriteLine("WELCOME TO ANGRY-OS!"          );        
        Console.WriteLine("DO NOT USE CAPS WHILE TYPEING!");
        Console.WriteLine("------------------------------");
        string UserInput;
        UserInput = Console.ReadLine();
        if (UserInput == "shutdown1")
        {
            Cosmos.Sys.Deboot.ShutDown();
        }
        else
            if (UserInput == "shutdown2")
            {
                Cosmos.Sys.Deboot.Reboot();
            }
            else
                if (UserInput == "help")
                {
                    Console.WriteLine("-------------------------------------");
                    Console.WriteLine("help: SHOWS THIS MESSAGE");
                    Console.WriteLine("version: DISPLAYS OS VERSION");
                    Console.WriteLine("about: DISPLAYS INFO ABOUT ANGRY OS");
                    Console.WriteLine("shutdown1: SHUTS DOWN THE OS");
                    Console.WriteLine("shutdown2: REBOOTS THE OS");
                    Console.WriteLine("hello or hi: DISPLAYS A HELLO WORLD");
                    Console.WriteLine("MESSAGE THAT WAS USED TO TEST THIS OS!!");
                    Console.WriteLine("-----------------------------------");
                }

        else
            if (UserInput == "version")
            {
                Console.WriteLine("--------------------");
                Console.WriteLine("ANGRY OS VERSION 0.1");
                Console.WriteLine("--------------------");
            }
            else
                if (UserInput == "about")
                {
                    Console.WriteLine("--------------------------------------------");
                    Console.WriteLine("ANGRY OS IS DEVELOPED BY ANGRYDEMON SOFTWARE");
                    Console.WriteLine("--------------------------------------------");
                }
                else
                    if (UserInput == "hello")
                    {
                        Console.WriteLine("------------");
                        Console.WriteLine("HELLO WORLD!");
                        Console.WriteLine("------------");
                    }
                    else
                        if (UserInput == "hi")
                        {
                            Console.WriteLine("------------");
                            Console.WriteLine("HELLO WORLD!");
                            Console.WriteLine("------------");
                        }

                        else
                        {
                            Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!");
                            Console.WriteLine("!!COULD NOT FIND COMMAND!!");
                            Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!");
                        }

        while (true)
            ;
    }
}
}
Oct 13, 2014 at 8:01 AM
Im new to C# so thanks for the help!
But are saying that if I remove the while true it would work?
Oct 13, 2014 at 2:37 PM
Thanks i think i do understand but i don't get what you mean by "get the users input all the way down to the end if the if-else block of commands" and the youtube video is useless when you only have Milestone 4, I can't get milestone 5 as i only have Visual C# 2008.

But you have been helpfull so far!
Oct 14, 2014 at 7:58 AM
Edited Oct 14, 2014 at 8:00 AM
Ok thanks I will try it out!
Also you have been really helpful, Anyway its not bad scripting for a 15 year old! ( :
PS how did you learn all this about Cosmos?
Oct 15, 2014 at 7:57 AM
Anyway the code you posted worked so thanks for the help! ( :