예제 #1
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        static void Main(string[] args)
        {
            var options = new Options();

            try
            {
                CommandLine.Parser.Default.ParseArguments(args, options);
            }
            catch (CommandLine.ParserException)
            {
                Console.Error.WriteLine("Failed to parse command line options.");
                Environment.Exit(-1);
            }

            try
            {
                Program.QueryAPIAndPrintResult(options.Term, options.Location);
            }
            catch (WebException error)
            {
                if (error.Response != null)
                    using (var reader = new StreamReader(error.Response.GetResponseStream()))
                    {
                        Console.Error.WriteLine("Response returned: {0}", reader.ReadToEnd());
                    }

                Console.Error.WriteLine("HTTP request failed, got {0}, abort program.", error.Message);

                Environment.Exit(-1);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: atiru/yelp-api
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        static void Main(string[] args)
        {
            var options = new Options();

            try
            {
                CommandLine.Parser.Default.ParseArguments(args, options);
            }
            catch (CommandLine.ParserException)
            {
                Console.Error.WriteLine("Failed to parse command line options.");
                Environment.Exit(-1);
            }

            try
            {
                Program.QueryAPIAndPrintResult(options.Term, options.Location);
            }
            catch (WebException error)
            {
                Console.Error.WriteLine("HTTP request failed, got {0}, abort program.", error.Message);
                Environment.Exit(-1);
            }
        }