예제 #1
0
        public static void Main(string[] args)
        {
            using (new LoggingScope(FindFile(LoggingScope.DefaultConfigFile)))
            {
                try
                {
                    Log.Debug($"New run with command line: {Environment.CommandLine}");
                    Log.Debug($"Current directory: {Environment.CurrentDirectory}");

                    var arguments = Arguments.Parse(args);
                    var options   = LoadOptions(arguments.Options);

                    var client = new TvDbClient(options.TvDb.ApiKey, options.TvDb.UserKey, options.TvDb.UserName);
                    client.Login().Wait();

                    var copier  = new Copier(arguments, client, options);
                    int matches = copier.CopyFiles().Result;

                    if (matches == 0)
                    {
                        Log.Warn($"No matches were found!");
                    }
                }
                catch (FatalException fe)
                {
                    Log.Error(fe.Message);
                }
                catch (AggregateException ae)
                {
                    if (ae.InnerException is FatalException)
                    {
                        Log.Error(ae.InnerException.Message);
                    }
                    else
                    {
                        Log.Error(ae);
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }