GetUsage() 개인적인 메소드

private GetUsage ( ) : string
리턴 string
예제 #1
0
파일: Program.cs 프로젝트: tvdburgt/subtle
        static int Main(string[] args)
        {
            Mapper.Initialize(cfg => cfg.AddProfile <OSDbProfile>());

            client  = new OSDbClient(OSDbClient.DefaultUserAgent);
            options = new SubtleOptions();
            CommandLine.Parser.Default.ParseArgumentsStrict(args, options);

            if (string.IsNullOrEmpty(options.Path))
            {
                Console.WriteLine("Missing path.");
                Console.WriteLine(options.GetUsage());
                return(1);
            }

            language = OSDbConfig.Languages.SingleOrDefault(l =>
                                                            options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) ||
                                                            options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase));

            if (language == null)
            {
                Console.WriteLine("Unrecognized language code.");
                Console.WriteLine(options.GetUsage());
                return(1);
            }

            return(MainAsync().GetAwaiter().GetResult());
        }
예제 #2
0
파일: Program.cs 프로젝트: tvdburgt/subtle
        static int Main(string[] args)
        {
            Mapper.Initialize(cfg => cfg.AddProfile<OSDbProfile>());

            client = new OSDbClient(OSDbClient.DefaultUserAgent);
            options = new SubtleOptions();
            CommandLine.Parser.Default.ParseArgumentsStrict(args, options);

            if (string.IsNullOrEmpty(options.Path))
            {
                Console.WriteLine("Missing path.");
                Console.WriteLine(options.GetUsage());
                return 1;
            }

            language = OSDbConfig.Languages.SingleOrDefault(l =>
                options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) ||
                options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase));

            if (language == null)
            {
                Console.WriteLine("Unrecognized language code.");
                Console.WriteLine(options.GetUsage());
                return 1;
            }

            return MainAsync().GetAwaiter().GetResult();
        }
예제 #3
0
        static void Main(string[] args)
        {
            client = new OSDbClient(OSDbClient.DefaultUserAgent);
            options = new SubtleOptions();
            CommandLine.Parser.Default.ParseArgumentsStrict(args, options);

            if (string.IsNullOrEmpty(options.Path))
            {
                Console.WriteLine("Missing path.");
                Console.WriteLine(options.GetUsage());
                Environment.Exit(1);
            }

            language = OSDbConfig.Languages.SingleOrDefault(l =>
                options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) ||
                options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase));

            if (language == null)
            {
                Console.WriteLine("Unrecognized language code.");
                Console.WriteLine(options.GetUsage());
                Environment.Exit(1);
            }

            if (Directory.Exists(options.Path))
            {
                client.InitSession();
                var results = ScanDirectory(options.Path)
                    .Select(SearchSubtitle)
                    .Where(s => s.Selection != null)
                    .ToList();

                if (!options.DryRun)
                {
                    Console.WriteLine();
                    DownloadSubtitles(results);
                }
            }
            else if (File.Exists(options.Path))
            {
                client.InitSession();
                var sub = SearchSubtitle(options.Path);
                if (sub.Selection != null && !options.DryRun)
                {
                    DownloadSubtitle(sub);
                }
            }
            else
            {
                Console.WriteLine("Path must be an existing file or directory.");
                Console.WriteLine(options.GetUsage());
                Environment.Exit(1);
            }
        }
예제 #4
0
파일: Program.cs 프로젝트: tvdburgt/subtle
        private static async Task <int> MainAsync()
        {
            IEnumerable <string> files = Enumerable.Empty <string>();

            if (Directory.Exists(options.Path))
            {
                files = ScanDirectory(options.Path);
            }
            else if (File.Exists(options.Path))
            {
                if (options.Replace || !HasSubtitle(options.Path))
                {
                    files = new[] { options.Path };
                }
            }
            else
            {
                Console.WriteLine("Path must be an existing file or directory.");
                Console.WriteLine(options.GetUsage());
                return(1);
            }

            await client.InitSessionAsync();

            var searchTasks = files.Select(f => SearchSubtitleAsync(f));

            var subs = (await Task.WhenAll(searchTasks)).AsEnumerable();

            subs = subs.Where(s => s.Selection != null);

            if (!options.DryRun && subs.Any())
            {
                Console.WriteLine();
                Console.WriteLine("Downloading...");
                await DownloadSubtitlesAsync(subs);

                Console.WriteLine("Done!");
            }

            return(0);
        }