예제 #1
0
        public static void Main(string[] args)
        {
            var pathToConfig = args.Length > 0 ? args[0] : DEFAULT_CONFIG_FILE;

            if (!File.Exists(pathToConfig))
            {
                Console.Error.WriteLine($"Could not find config file in path: {pathToConfig}");
                System.Environment.Exit(1);
            }

            using (var file = File.OpenRead(pathToConfig))
            {
                if (!ZMIParser.TryParseZMI(new StreamReader(file), ref _root))
                {
                    Console.Error.WriteLine($"Could not parse ZMI from file: {pathToConfig}");
                    System.Environment.Exit(1);
                }
            }

            var    scanner = Console.In;
            string line;

            while ((line = scanner.ReadLine()) != null)
            {
                var inputLine = line.Split(':');
                if (inputLine.Length > 2)
                {
                    Console.Error.WriteLine($"Wrong input");
                    continue;
                }

                var query = inputLine.Length == 2 ? inputLine[1] : inputLine[0];
                Interpreter.ExecuteQueries(_root, query.TrimEnd(';'), long.MaxValue, true);
            }
        }
예제 #2
0
파일: Server.cs 프로젝트: swtwsk/cloudatlas
        private static bool TryParseConfig(string pathToConfig, out ZMI zmi)
        {
            zmi = null;

            if (!File.Exists(pathToConfig))
            {
                Console.Error.WriteLine($"Could not find config file in path: {pathToConfig}");
                return(false);
            }

            using var file = File.OpenRead(pathToConfig);
            if (ZMIParser.TryParseZMI(new StreamReader(file), ref zmi))
            {
                return(true);
            }

            Console.Error.WriteLine($"Could not parse ZMI from file: {pathToConfig}");
            return(false);
        }