Пример #1
0
        static void PrintHelp()
        {
            Console.Instance.WriteLine(
                "Hitomi Console Core\r\n" +
                "\r\n"
                //" -article <Hitomi Number> : Show article info.\r\n" +
                //" -image <Hitomi Number> [-type=small | big]: Get Image Link.\r\n" +
                //" -downloadmetadata, -loadmetadata, -downloadhidden, -loadhidden, -sync, -load : Manage Metadata.\r\n" +
                //" -search <Search What> [-all] : Language Dependent metadata seraching.\r\n" +
                //" -setsearch <Place What> : Fix specific search token.\r\n" +
                //" -syncdate : Synchronize HitomiDate data.\r\n" +
                //" -rank : Show artists recommendation artist list\r\n" +
                //" -taglist : Show downloaded article's tag list"
                );

            var builder = new StringBuilder();

            CommandLineParser <HitomiConsoleOption> .GetFields().ToList().ForEach(
                x =>
            {
                if (!string.IsNullOrEmpty(x.Value.Item2.Help))
                {
                    builder.Append($" {x.Key} ({x.Value.Item2.Help}) : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
                else
                {
                    builder.Append($" {x.Key} : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
            });

            Console.Instance.WriteLine(builder.ToString());
        }
Пример #2
0
        static void PrintHelp()
        {
            Console.Instance.WriteLine(
                "Internal Console\r\n" +
                "\r\n" +
                " -e [-F | -P | -I | -S] <path> : Enumerate method."
                );

            var builder = new StringBuilder();

            CommandLineParser <InternalConsoleOption> .GetFields().ToList().ForEach(
                x =>
            {
                if (!string.IsNullOrEmpty(x.Value.Item2.Help))
                {
                    builder.Append($" {x.Key} ({x.Value.Item2.Help}) : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
                else
                {
                    builder.Append($" {x.Key} : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
            });

            Console.Instance.WriteLine(builder.ToString());
        }
        /// <summary>
        /// 형식에 어긋난 인자가 있다면 그것을 가져옵니다.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="argv"></param>
        /// <returns></returns>
        public static List <int> GetWeirdArguments <T>(string[] argv)
            where T : IConsoleOption, new()
        {
            var field = CommandLineParser <T> .GetFields();

            List <int> result = new List <int>();

            for (int i = 0; i < argv.Length; i++)
            {
                string token = argv[i].Split('=')[0];
                if (field.ContainsKey(token))
                {
                    var cl = field[token];
                    if (cl.Item2.CType == CommandType.ARGUMENTS)
                    {
                        i += cl.Item2.ArgumentsCount;
                    }
                }
                else
                {
                    result.Add(i);
                }
            }

            return(result);
        }
Пример #4
0
        static void PrintHelp()
        {
            PrintVersion();
            System.Console.WriteLine($"Copyright (C) 2019. Koromo Copy Developer");
            System.Console.WriteLine($"E-Mail: [email protected]");
            System.Console.WriteLine($"Source-code: https://github.com/koromo-copy/koromo-copy");
            System.Console.WriteLine($"");
            System.Console.WriteLine("Usage: ./Koromo_Copy.Console [OPTIONS...] <URL> [URL OPTIONS ...]");

            var builder = new StringBuilder();

            CommandLineParser.GetFields(typeof(Options)).ToList().ForEach(
                x =>
            {
                var key = x.Key;
                if (!key.StartsWith("--"))
                {
                    return;
                }
                if (!string.IsNullOrEmpty(x.Value.Item2.ShortOption))
                {
                    key = $"{x.Value.Item2.ShortOption}, " + key;
                }
                var help = "";
                if (!string.IsNullOrEmpty(x.Value.Item2.Help))
                {
                    help = $"[{x.Value.Item2.Help}]";
                }
                if (!string.IsNullOrEmpty(x.Value.Item2.Info))
                {
                    builder.Append($"   {key}".PadRight(30) + $" {x.Value.Item2.Info} {help}\r\n");
                }
                else
                {
                    builder.Append($"   {key}".PadRight(30) + $" {help}\r\n");
                }
            });
            System.Console.Write(builder.ToString());

            System.Console.WriteLine($"");
            System.Console.WriteLine("Enter './Koromo_Copy.Console --list-extractor' to get more url options.");
        }
Пример #5
0
        static void PrintHelp()
        {
            Console.Instance.WriteLine(
                "DCInside Console Core\r\n" +
                "\r\n"
                );

            var builder = new StringBuilder();

            CommandLineParser <DCInsideConsoleOption> .GetFields().ToList().ForEach(
                x =>
            {
                if (!string.IsNullOrEmpty(x.Value.Item2.Help))
                {
                    builder.Append($" {x.Key} ({x.Value.Item2.Help}) : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
                else
                {
                    builder.Append($" {x.Key} : {x.Value.Item2.Info} [{x.Value.Item1}]\r\n");
                }
            });

            Console.Instance.WriteLine(builder.ToString());
        }
Пример #6
0
        public static void Start(string[] arguments)
        {
            var origin = arguments;

            arguments = CommandLineUtil.SplitCombinedOptions(arguments);
            arguments = CommandLineUtil.InsertWeirdArguments <Options>(arguments, true, "--url");
            var option = CommandLineParser.Parse <Options>(arguments);

            //
            //  Multi Commands
            //
            if (option.Net)
            {
                NetConsole.Start(origin.Skip(1).ToArray());
            }
            //
            //  Single Commands
            //
            else if (option.Help)
            {
                PrintHelp();
            }
            else if (option.Version)
            {
                PrintVersion();
            }
            else if (option.DialogMode)
            {
                Dialog.StartDialog();
            }
            else if (option.ListExtractor)
            {
                foreach (var extractor in ExtractorManager.Extractors)
                {
                    System.Console.WriteLine($"[{extractor.GetType().Name}]");
                    System.Console.WriteLine($"[HostName] {extractor.HostName}");
                    System.Console.WriteLine($"[Checker] {extractor.ValidUrl}");
                    System.Console.WriteLine($"[Information] {extractor.ExtractorInfo}");
                    var builder = new StringBuilder();
                    CommandLineParser.GetFields(extractor.RecommendOption("").GetType()).ToList().ForEach(
                        x =>
                    {
                        var key = x.Key;
                        if (!key.StartsWith("--"))
                        {
                            return;
                        }
                        if (!string.IsNullOrEmpty(x.Value.Item2.ShortOption))
                        {
                            key = $"{x.Value.Item2.ShortOption}, " + key;
                        }
                        var help = "";
                        if (!string.IsNullOrEmpty(x.Value.Item2.Help))
                        {
                            help = $"[{x.Value.Item2.Help}]";
                        }
                        if (!string.IsNullOrEmpty(x.Value.Item2.Info))
                        {
                            builder.Append($"   {key}".PadRight(30) + $" {x.Value.Item2.Info} {help}\r\n");
                        }
                        else
                        {
                            builder.Append($"   {key}".PadRight(30) + $" {help}\r\n");
                        }
                    });
                    if (builder.ToString() != "")
                    {
                        System.Console.WriteLine($"[Options]");
                        System.Console.Write(builder.ToString());
                    }
                    System.Console.WriteLine($"-------------------------------------------------------------");
                }
            }
            else if (option.Url != null)
            {
                if (!(option.Url[0].StartsWith("https://") || option.Url[0].StartsWith("http://")))
                {
                    System.Console.WriteLine($"'{option.Url[0]}' is not correct url format or not supported scheme.");
                }

                var weird  = CommandLineUtil.GetWeirdArguments <Options>(arguments);
                var n_args = new List <string>();

                weird.ForEach(x => n_args.Add(arguments[x]));

                ProcessExtract(option.Url[0], n_args.ToArray(), option.PathFormat, option.ExtractInformation, option.ExtractLinks, option.PrintProcess, option.DisableDownloadProgress);
            }
            else if (option.Error)
            {
                System.Console.WriteLine(option.ErrorMessage);
                if (option.HelpMessage != null)
                {
                    System.Console.WriteLine(option.HelpMessage);
                }
                return;
            }
            else
            {
                System.Console.WriteLine("Nothing to work on.");
                System.Console.WriteLine("Enter './Koromo_Copy.Console --help' to get more information");
            }

            return;
        }