/// <summary> /// Test 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <TestConsoleOption>(arguments, true, "--cmd"); TestConsoleOption option = CommandLineParser <TestConsoleOption> .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.Commands != null) { ProcessTest(option.Commands); } return(true); }
/// <summary> /// Out 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.InsertWeirdArguments <OutConsoleOption>(arguments, contents != "", "-o"); OutConsoleOption option = CommandLineParser <OutConsoleOption> .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.Output != null) { ProcessOut(option.Output, contents, option.Overwrite); } return(true); }
/// <summary> /// 다운로드 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.InsertWeirdArguments <DownloadConsoleOption>(arguments, contents == "", "--url"); DownloadConsoleOption option = CommandLineParser <DownloadConsoleOption> .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.Url != null) { ProcessUrl(option.Url, option.Out); } else if (contents != "") { ProcessUrls(contents, option.Out); } return(true); }
public static void Start(string[] arguments) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <Options>(arguments, true, "--url"); var option = CommandLineParser.Parse <Options>(arguments); if (option.Help) { PrintHelp(); } else if (option.Version) { PrintVersion(); } else if (option.Error) { Console.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.WriteLine(option.HelpMessage); } return; } else { Console.WriteLine("Nothing to work on."); Console.WriteLine("Enter './Koromo_Copy.Bot --help' to get more information"); } return; }
/// <summary> /// Scan 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <ScanConsoleOption>(arguments, true, "--dir"); ScanConsoleOption option = CommandLineParser <ScanConsoleOption> .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.Directory != null) { ProcessDirectory(option.Directory, option.Recursive, option.WithFiles); } return(true); }
/// <summary> /// In 콘솔 리다이렉트 /// </summary> static bool Redirect(string[] arguments, string contents) { arguments = CommandLineUtil.InsertWeirdArguments <InConsoleOption>(arguments, true, "-i"); InConsoleOption option = CommandLineParser <InConsoleOption> .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.Input != null) { ProcessIn(option.Input); } return(true); }
/// <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); } return(true); }
public static void Start(string[] arguments) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <Options>(arguments, true, "--url"); var option = CommandLineParser.Parse <Options>(arguments); // // Single Commands // if (option.Help) { PrintHelp(); } else if (option.Version) { PrintVersion(); } else if (option.RecoverSettings) { Settings.Instance.Recover(); Settings.Instance.Save(); } else if (option.Start) { ProcessStart(); } else if (option.Error) { Console.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.WriteLine(option.HelpMessage); } return; } else { Console.WriteLine("Nothing to work on."); Console.WriteLine("Enter './hsync --help' to get more information"); } return; }
/// <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); }
public static void Start(string[] arguments) { arguments = CommandLineUtil.SplitCombinedOptions(arguments); arguments = CommandLineUtil.InsertWeirdArguments <Options>(arguments, true, "--url"); var option = CommandLineParser.Parse <Options>(arguments); // // Single Commands // if (option.Help) { PrintHelp(); } else if (option.Version) { PrintVersion(); } else if (option.RecoverSettings) { Settings.Instance.Recover(); Settings.Instance.Save(); } else if (option.BuildData) { ProcessBuildData(); } else if (option.StartsWithClient) { ProcessStartsWithClient(); } else if (option.ListExtractor) { foreach (var extractor in ExtractorManager.Extractors) { Console.WriteLine($"[{extractor.GetType().Name}]"); Console.WriteLine($"[HostName] {extractor.HostName}"); Console.WriteLine($"[Checker] {extractor.ValidUrl}"); 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() != "") { Console.WriteLine($"[Options]"); Console.Write(builder.ToString()); } Console.WriteLine($"-------------------------------------------------------------"); } } else if (option.Url != null) { if (!(option.Url[0].StartsWith("https://") || option.Url[0].StartsWith("http://"))) { 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) { Console.WriteLine(option.ErrorMessage); if (option.HelpMessage != null) { Console.WriteLine(option.HelpMessage); } return; } else { Console.WriteLine("Nothing to work on."); Console.WriteLine("Enter './custom-copy-backend --help' to get more information"); } return; }