Exemplo n.º 1
0
Arquivo: bcl.cs Projeto: xyuan/BoSSS
        /// <summary>
        /// performs the subprogram-decoding;
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            myEnv = new MyEnvironment();
            if (args.Length < 1)
            {
                PrintUsage();
                return;
            }

            string command = args[0];

            string[] cmdrest = new string[args.Length - 1];
            if (cmdrest.Length > 0)
            {
                Array.Copy(args, 1, cmdrest, 0, cmdrest.Length);
            }

            IProgram p = null;

            try {
                p = ProgramFactory(command);

                if (cmdrest.Length == 1 && cmdrest[0].Equals("?"))
                {
                    PrintUsage(p);
                }
                else
                {
                    p.DecodeArgs(cmdrest);
                    p.Execute();
                }
            } catch (UserInputException uie) {
                Console.WriteLine("ERROR: bad user input: " + uie.Message);
                Console.WriteLine();
                if (p == null)
                {
                    PrintUsage();
                }
                else
                {
                    PrintUsage(p);
                }
                Environment.Exit(-1);
            } catch (EnviromentException ee) {
                Console.WriteLine("ERROR: BoSSS environment: " + ee.Message);
                Console.WriteLine();
                Environment.Exit(-2);
            }
        }