/// <summary> /// Internal 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); if (CommandLineUtil.AnyArgument(arguments, "-e")) { arguments = CommandLineUtil.DeleteArgument(arguments, "-e"); if (!CommandLineUtil.AnyStrings(arguments)) { arguments = CommandLineUtil.PushFront(arguments, ""); } } arguments = CommandLineUtil.InsertWeirdArguments <InternalConsoleOption>(arguments, true, "-e"); InternalConsoleOption option = CommandLineParser <InternalConsoleOption> .Parse(arguments); if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Enumerate != null) { ProcessEnumerate(option.Enumerate, option.EnumerateWithForms, option.EnumerateWithPrivate, option.EnumerateWithInstances, option.EnumerateWithStatic, option.EnumerateWithMethod); } else if (option.Get != null) { ProcessGet(option.Get, option.EnumerateWithForms, option.EnumerateWithInstances, option.EnumerateWithPrivate); } else if (option.Set != null) { ProcessSet(option.Set, option.EnumerateWithForms, option.EnumerateWithInstances); } else if (option.Call != null) { ProcessCall(option.Call, option.EnumerateWithForms, option.EnumerateWithInstances, option.CallWithReturn, option.CallOnAnotherThread); } return(true); }
/// <summary> /// 익헨 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { ExHentaiConsoleOption option = CommandLineParser <ExHentaiConsoleOption> .Parse(arguments, contents != "", contents); if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Article != null) { ProcessArticle(option.Article); } else if (option.Address != null) { ProcessAddress(option.Address); } else if (option.Paging != null) { ProcessPaging(option.Paging); } else if (option.Expun != null) { ProcessExpun(option.Expun); } else if (option.Hashing) { ProcessHashing(); } else if (option.XXX) { ProcessXXX(); } return(true); }
/// <summary> /// Script 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { LPConsoleOption option = CommandLineParser <LPConsoleOption> .Parse(arguments); if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Kor2Eng != null) { ProcessKor2Eng(option.Kor2Eng); } else if (option.Eng2Kor != null) { ProcessEng2Kor(option.Eng2Kor); } else if (option.Regex != null) { ProcessRegex(option.Regex); } else if (option.PSGample) { ProcessPGSample(); } else if (option.Test != null) { ProcessTest(option.Test); } return(true); }
/// <summary> /// Grep 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <GrepConsoleOption>(arguments, contents != "", "--p"); GrepConsoleOption option = CommandLineParser <GrepConsoleOption> .Parse(arguments, contents != "", contents); if (option.Input == null) { option.Input = new[] { contents }; } if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Input == null) { Console.Instance.WriteErrorLine("Input is empty."); } else if (option.Pattern == null) { Console.Instance.WriteErrorLine("Pattern is empty."); } else { ProcessGrep(option.Input[0], option.Pattern[0], option.UsingRegex, option.ShowNumber, option.IgnoreCase); } return(true); }
/// <summary> /// 익헨 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { YoutubeConsoleOption option = CommandLineParser <YoutubeConsoleOption> .Parse(arguments, contents != "", contents); if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Info != null) { ProcessInfo(option.Info); } return(true); }
/// <summary> /// 히토미 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { HitomiConsoleOption option = CommandLineParser <HitomiConsoleOption> .Parse(arguments); if (option.Error) { Console.Instance.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.Instance.WriteLine(option.HelpMessage); } return(false); } else if (option.Help) { PrintHelp(); } else if (option.Article != null) { ProcessArticle(option.Article); } else if (option.ImageLink != null) { ProcessImage(option.ImageLink, option.Type); } // // 다운로드 관련 // else if (option.DownloadMetadata) { Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore."); return(true); //ProcessDownloadMetadata(); } else if (option.LoadMetadata) { ProcessLoadMetadata(); } else if (option.DownloadHidden) { Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore."); return(true); //ProcessDownloadHidden(); } else if (option.LoadHidden) { ProcessLoadHidden(); } // // 로드 및 동기화 // else if (option.Sync) { Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore."); return(true); //ProcessSync(); } else if (option.Load) { ProcessLoad(); } // // 검색 // else if (option.Search != null) { ProcessSearch(option.Search, option.ShowAllSearchList); } else if (option.SetSearchToken != null) { Instance.setter = option.SetSearchToken[0]; } // // Date 동기화 // else if (option.SyncDate) { HitomiDate.print_datetime_data(); } else if (option.Latest) { ProcessLatest(); } // // 작가 추천 // else if (option.Rank) { ProcessRank(); } else if (option.TagList) { ProcessTagList(); } // // 단순 통계 // else if (option.Ranking) { ProcessRanking(); } // // Forbidden 데이터 // else if (option.Forbidden != null) { ProcessForbidden(option.Forbidden); } // // 로그 복구 // else if (option.LogRecover != null) { ProcessRecoverLog(option.LogRecover); } // // 테스트 // else if (option.Test != null) { ProcessTest(option.Test); } return(true); }
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; }