public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine(@"Index directory argument is required. Example: bobo.exe ""C:\IndexDirectory\"". Press a key to exit.");
                Console.ReadKey();
                return (int)ResultCodes.NO_INDEX_PROVIDED;
            }

            string path = args[0];

            try
            {
                if (!Directory.Exists(Path.GetFullPath(path)))
                {
                    Console.WriteLine("ERROR: The directory doesn't exist. Press a key to exit.");
                    Console.ReadKey();
                    return (int)ResultCodes.DIRECTORY_DOESNT_EXIST;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(@"ERROR: Argument passed must be a valid directory or file name.  Press a key to exit." + 
                    Environment.NewLine + "Original Error: " + Environment.NewLine + e.ToString());
                Console.ReadKey();
                return (int)ResultCodes.DIRECTORY_INVALID;
            }

            DirectoryInfo idxDir = new DirectoryInfo(Path.GetDirectoryName(args[0]));
            Console.WriteLine("Index directory: " + idxDir.FullName);
            Console.WriteLine("Welcome to the bobo console utility. Type 'help' to see a list of supported commands.");

            IBrowseService svc = new BrowseServiceImpl(idxDir);
            string line;

            using (var app = new BoboCmdlineApp(svc))
            {
                while (true)
                {
                    try
                    {
                        Console.WriteLine("bobo> ");

                        line = Console.ReadLine();
                        if (line.Equals("exit", StringComparison.OrdinalIgnoreCase) || line.Equals("q", StringComparison.OrdinalIgnoreCase))
                        {
                            break;
                        }

                        app.ProcessCommand(line);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
            }

            return (int)ResultCodes.SUCCESS;
        }
Exemple #2
0
        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine(@"Index directory argument is required. Example: bobo.exe ""C:\IndexDirectory\"". Press a key to exit.");
                Console.ReadKey();
                return((int)ResultCodes.NO_INDEX_PROVIDED);
            }

            string path = string.Empty;

            try
            {
                path = Path.GetDirectoryName(Path.GetFullPath(args[0]));
                if (!Directory.Exists(path))
                {
                    Console.WriteLine("ERROR: The directory doesn't exist. Press a key to exit.");
                    Console.ReadKey();
                    return((int)ResultCodes.DIRECTORY_DOESNT_EXIST);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(@"ERROR: Argument passed must be a valid directory or file name.  Press a key to exit." +
                                  Environment.NewLine + "Original Error: " + Environment.NewLine + e.ToString());
                Console.ReadKey();
                return((int)ResultCodes.DIRECTORY_INVALID);
            }

            DirectoryInfo idxDir = new DirectoryInfo(path);

            Console.WriteLine("Index directory: " + idxDir.FullName);
            Console.WriteLine("Welcome to the bobo console utility. Type 'help' to see a list of supported commands.");

            IBrowseService svc = new BrowseServiceImpl(idxDir);
            string         line;

            using (var app = new BoboCmdlineApp(svc))
            {
                while (true)
                {
                    try
                    {
                        Console.WriteLine("bobo> ");

                        line = Console.ReadLine();
                        if (line.Equals("exit", StringComparison.OrdinalIgnoreCase) || line.Equals("q", StringComparison.OrdinalIgnoreCase))
                        {
                            break;
                        }

                        app.ProcessCommand(line);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
            }

            return((int)ResultCodes.SUCCESS);
        }