Пример #1
0
        public static bool ClearCommand(string[] args)
        {
            if (args[0] == "help")
            {
                Console.WriteLine("Usage: clear");
                Console.WriteLine("Clears console.");
                return(true);
            }

            RConsoleBase.Clear();
            return(true);
        }
Пример #2
0
        static void Main(string[] args)
        {
            RConsoleBase console = new RConsoleBase();

            if (args.Length > 0)
            {
                console.TempRun(args);
            }
            else
            {
                console.Run();
            }
        }
Пример #3
0
        /*
         * private static TextWriter writer;
         * private static TextReader reader;
         */

        ///////////////////////////////////////


        public RConsoleBase()
        {
            console = this;

            RConsoleBaseHelper.console = console;

            cHandler = new CommandHandler();

            bManager = new BluetoothManager(console);

            serial = new SerialCommunication(console);
            serial.Run();

            context = new Context();
        }
Пример #4
0
 public SerialCommunication(RConsoleBase console)
 {
     this.console = console;
 }
Пример #5
0
        // Handles command inputs and makes sure everything gets handled properly.
        public bool Handle(string[] args)
        {
            // If no args, return false
            if (args.Length == 0)
            {
                return(false);
            }


            bool result;

            //  Run commands for instance if current instance isn't base instance
            if (RConsoleBase.GetInstance() != "base")
            {
                if (args[0] == "quit")
                {
                    RConsoleBase.ResetInstance();
                    return(true);
                }
                else
                {
                    result = commands[RConsoleBase.GetInstance()].Execute(args);

                    if (!result)
                    {
                        // Calls commands with "help" argument
                        commands[RConsoleBase.GetInstance()].Execute(new string[] { "help" });
                        return(false);
                    }

                    return(true);
                }
            }


            Command command;

            if (commands.ContainsKey(args[0]))
            {
                // Get Command object from dictionary by passing the "command name" by string.
                command = commands[args[0]];
            }
            else
            {
                // No command of name args[0]
                return(false);
            }

            // Throwing out the command name from the input arguments
            args = args.Skip(1).ToArray();


            if (args.Length == 0)
            {
                // if command can be an instance and current instance is not command, set current instance to command
                if (command.IsInstance && RConsoleBase.GetInstance() != command.Name)
                {
                    RConsoleBase.SetInstance(command.Name);
                    return(true);
                }
                else
                {
                    // place holder
                    args = new string[1];
                }
            }


            // finally, execute command with args in the normal fashion
            result = command.Execute(args);

            if (!result)
            {
                // Calls command with "help" argument
                command.Execute(new string[] { "help" });
                return(false);
            }

            return(true);
        }
Пример #6
0
 public BluetoothManager(RConsoleBase console)
 {
     this.console = console;
 }