Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ConsoleWindow.EnableQuickEditMode(false);
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            var options = CommandLineUtil.ParseOptions <CommandLineOptions>(args);

            FileRecordCacheManager.Ins.Init(!options.DisableCache);

            StringTemplateManager.Ins.Init(!options.DisableCache);
            if (!string.IsNullOrEmpty(options.TemplateSearchPath))
            {
                StringTemplateManager.Ins.AddTemplateSearchPath(options.TemplateSearchPath);
            }
            StringTemplateManager.Ins.AddTemplateSearchPath(FileUtil.GetPathRelateApplicationDirectory("Templates"));

            Luban.Common.Utils.LogUtil.InitSimpleNLogConfigure(NLog.LogLevel.FromString(options.LogLevel));

            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            TimeZoneUtil.InitDefaultTimeZone(options.L10nDefaultTimeZone);

            GenServer.Ins.Start(false, options.Port, ProtocolStub.Factories);

            GenServer.Ins.RegisterJob("cfg", new Luban.Job.Cfg.JobController());
            GenServer.Ins.RegisterJob("proto", new Luban.Job.Proto.JobController());
            GenServer.Ins.RegisterJob("db", new Luban.Job.Db.JobController());

            int processorCount = System.Environment.ProcessorCount;

            ThreadPool.SetMinThreads(Math.Max(4, processorCount), 5);
            ThreadPool.SetMaxThreads(Math.Max(16, processorCount * 4), 10);

            Console.WriteLine("== running ==");
        }
Exemplo n.º 2
0
        /// <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>
        /// 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);
        }
Exemplo n.º 4
0
        private void ParseArguments(string commandLine)
        {
            var args = CommandLineUtil.Parse(commandLine);

            foreach (string arg in args.Skip(1))
            {
                if (File.Exists(arg) && Path.HasExtension(arg))
                {
                    switch (Path.GetExtension(arg).ToLowerInvariant())
                    {
                    case ".js":
                        EnsureJavaScriptForm();
                        _javaScriptForm.OpenEditor(arg);
                        break;

                    case ".weproj":
                        EnsureJavaScriptForm();
                        _javaScriptForm.OpenProject(arg);
                        break;

                    case ".wqpkg":
                    case ".wqreport":
                    case ".wqexport":
                        AddFile(arg);
                        return;
                    }
                }
            }
        }
        /// <summary>
        ///     The name(s) of the workers to build. Specify multiple targets by separating them with a comma.
        ///     For example: "UnityClient,UnityWorker".
        /// </summary>
        /// <remarks>
        ///     Currently, the only possible values are "UnityWorker" and "UnityClient".
        ///     Defaults to AllWorkerTypes if the flag is not specified.
        ///     If commandLine is null, defaults to using <code>Environment.GetCommandLineArgs();</code>.
        /// </remarks>
        public static IList <string> GetWorkerTypesToBuild(string[] commandLine = null)
        {
            if (WorkersToBuild != null)
            {
                if (!WorkersToBuild.Any())
                {
                    return(AllWorkerTypes);
                }

                return(WorkersToBuild);
            }


            if (commandLine == null)
            {
                commandLine = Environment.GetCommandLineArgs();
            }

            var commandLineValue = CommandLineUtil.GetCommandLineValue(commandLine, ConfigNames.BuildWorkerTypes, string.Empty);

            if (string.IsNullOrEmpty(commandLineValue))
            {
                return(AllWorkerTypes);
            }

            return(ParseWorkerTypes(commandLineValue));
        }
Exemplo n.º 6
0
        /// <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>
        ///     Build method that is invoked by commandline
        /// </summary>
        public static void Build()
        {
            try
            {
                var commandLine = Environment.GetCommandLineArgs();

                Debug.LogFormat("Want to build with args: {0}", String.Join(", ", commandLine));

                var buildTargetArg =
                    CommandLineUtil.GetCommandLineValue(commandLine, "buildTarget", "local");

                if (string.IsNullOrEmpty(buildTargetArg))
                {
                    // The default above does not get filled when -t parameter is not passed
                    buildTargetArg = BuildEnvironment.Local.ToString();
                    Debug.LogWarningFormat("Using default build target value: \"{0}\".", buildTargetArg);
                }

                BuildEnvironment buildEnvironment;

                switch (buildTargetArg.ToLower())
                {
                case "cloud":
                    buildEnvironment = BuildEnvironment.Cloud;
                    break;

                case "local":
                    buildEnvironment = BuildEnvironment.Local;
                    break;

                default:
                    throw new BuildFailedException("Unknown build target value: " + buildTargetArg);
                }

                var workerTypesArg =
                    CommandLineUtil.GetCommandLineValue(commandLine, ConfigNames.BuildWorkerTypes,
                                                        "UnityClient,UnityWorker");

                var wantedWorkerPlatforms = GetWorkerPlatforms(workerTypesArg);

                SpatialCommands.GenerateBuildConfiguration();

                foreach (var workerPlatform in wantedWorkerPlatforms)
                {
                    BuildWorkerForEnvironment(workerPlatform, buildEnvironment);
                }
            }
            catch (Exception e)
            {
                // Log the exception so it appears in the command line, and rethrow as a BuildFailedException so the build fails.
                Debug.LogException(e);

                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        public static IndexUpgrader ParseArgs(string[] args)
        {
            string     path = null;
            bool       deletePriorCommits = false;
            TextWriter @out    = null;
            string     dirImpl = null;
            int        i       = 0;

            while (i < args.Length)
            {
                string arg = args[i];
                if ("-delete-prior-commits".Equals(arg, StringComparison.Ordinal))
                {
                    deletePriorCommits = true;
                }
                else if ("-verbose".Equals(arg, StringComparison.Ordinal))
                {
                    @out = Console.Out;
                }
                else if ("-dir-impl".Equals(arg, StringComparison.Ordinal))
                {
                    if (i == args.Length - 1)
                    {
                        throw new ArgumentException("ERROR: missing value for -dir option");
                        //Console.WriteLine("ERROR: missing value for -dir-impl option");
                        //Environment.FailFast("1");
                    }
                    i++;
                    dirImpl = args[i];
                }
                else if (path == null)
                {
                    path = arg;
                }
                else
                {
                    PrintUsage();
                }
                i++;
            }
            if (path == null)
            {
                PrintUsage();
            }

            Directory dir = null;

            if (dirImpl == null)
            {
                dir = FSDirectory.Open(new DirectoryInfo(path));
            }
            else
            {
                dir = CommandLineUtil.NewFSDirectory(dirImpl, new DirectoryInfo(path));
            }
#pragma warning disable 612, 618
            return(new IndexUpgrader(dir, LuceneVersion.LUCENE_CURRENT, @out, deletePriorCommits));

#pragma warning restore 612, 618
        }
Exemplo n.º 12
0
        /// <summary>
        /// Extract private key by keystore
        /// </summary>
        /// <param name="parameters">
        /// Parameters Index
        /// </param>
        /// <returns></returns>
        public static bool BackupWallet(string command, string[] parameters)
        {
            string[] usage = new string[] {
                string.Format("{0} [command option] <path>\n", command)
            };

            string[] command_option = new string[] { HelpCommandOption.Help };

            if (parameters != null)
            {
                OutputHelpMessage(usage, null, command_option, null);
                return(true);
            }

            if (!RpcApi.IsLogin)
            {
                return(true);
            }

            try
            {
                string       password = CommandLineUtil.ReadPasswordString("Please input your password.");
                RpcApiResult result   = RpcApi.BackupWallet(password);

                OutputResultMessage(command, result.Result, result.Code, result.Message);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
            }
            return(true);
        }
Exemplo n.º 13
0
        public static void Execute(ProgramExecutionOptions options)
        {
            if (ProgramUtil.ShowHelpIfNeeded(options))
            {
                return;
            }

            if (CommandLineUtil.ValidateArguments(options.ParsedArguments, Validations))
            {
                var target   = CommandLineUtil.FindArgumentByName(options.ParsedArguments, TargetArgName).Value;
                var userName = CommandLineUtil.FindArgumentByName(options.ParsedArguments, UserNameArgName).Value;
                var password = CommandLineUtil.FindArgumentByName(options.ParsedArguments, PasswordArgName).Value;

                var device = DeviceUtil.FindDeviceByIpOrName(target);
                if (device == null)
                {
                    var msg = string.Format("No device found with IP or Name equal to '{0}'.", target);
                    msg = TextUtil.Error(msg);
                    TerminalUtil.ShowText(msg);
                }
                else
                {
                    RunOnDevice(device, userName, password);
                }
            }
            else
            {
                TerminalUtil.ShowText("ERROR, PLEASE USE HELP. DUMB ASS");
            }
        }
Exemplo n.º 14
0
        public static void Main(string[] args)
        {
            foreach (var arg in args)
            {
                if (arg.Equals("--help"))
                {
                    Console.Write(CommandLineUtil.HelpText(cmdLineExample, typeof(LocalProjectRunnerArguments)));
                    return;
                }
            }

            var cmdOptions = CommandLineUtil.ParseArguments <CommandLineOptions>(args);

            if (cmdOptions != null)
            {
                if (cmdOptions.ConfigurationFilePath != null)
                {
                    TestCommons.RunWithConfiguration(File.ReadAllText(cmdOptions.ConfigurationFilePath));
                }
                else
                {
                    string[] unknownArgs         = new string[0];
                    Type     runnerArgumentsType = cmdOptions.TestSource.GetArgumentsType();
                    int      firstUnknownArg     = CommandLineUtil.FindFirstUknownArg(args, runnerArgumentsType);
                    if (firstUnknownArg >= 0)
                    {
                        unknownArgs = args.Skip(firstUnknownArg).ToArray();
                    }

                    ProjectRunnerArguments runnerArgs = CommandLineUtil.ParseArguments(args, runnerArgumentsType) as ProjectRunnerArguments;
                    runnerArgs.TestingFrameworkArguments = unknownArgs;
                    TestCommons.RunWithArgs(runnerArgs);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Main method to run {code IndexUpgrader} from the
        ///  command-line.
        /// </summary>

        /*public static void Main(string[] args)
         * {
         * ParseArgs(args).Upgrade();
         * }*/

        public static IndexUpgrader ParseArgs(string[] args)
        {
            string     path = null;
            bool       deletePriorCommits = false;
            TextWriter @out    = null;
            string     dirImpl = null;
            int        i       = 0;

            while (i < args.Length)
            {
                string arg = args[i];
                if ("-delete-prior-commits".Equals(arg))
                {
                    deletePriorCommits = true;
                }
                else if ("-verbose".Equals(arg))
                {
                    @out = Console.Out;
                }
                else if ("-dir-impl".Equals(arg))
                {
                    if (i == args.Length - 1)
                    {
                        Console.WriteLine("ERROR: missing value for -dir-impl option");
                        Environment.Exit(1);
                    }
                    i++;
                    dirImpl = args[i];
                }
                else if (path == null)
                {
                    path = arg;
                }
                else
                {
                    PrintUsage();
                }
                i++;
            }
            if (path == null)
            {
                PrintUsage();
            }

            Directory dir = null;

            if (dirImpl == null)
            {
                dir = FSDirectory.Open(new DirectoryInfo(path));
            }
            else
            {
                dir = CommandLineUtil.NewFSDirectory(dirImpl, new DirectoryInfo(path));
            }
            return(new IndexUpgrader(dir, LuceneVersion.LUCENE_CURRENT, @out, deletePriorCommits));
        }
        /// <summary>
        ///     Gets a value specified on the command line, in the form "+key" "value"
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="configKey">The name of the key, without the leading +, e.g. "key"</param>
        /// <param name="defaultValue">The value to return if the key was not specified on the command line.</param>
        /// <returns>The value of the key, or defaultValue if the key was not specified on the command line.</returns>
        public T GetCommandLineValue<T>(string configKey, T defaultValue)
        {
            T configValue;
            if (CommandLineUtil.TryGetConfigValue(commandLineDictionary, configKey, out configValue))
            {
                return configValue;
            }

            return defaultValue;
        }
 public void runClass
     (IDictionary <string, int> files,
     IDictionary <string, int> enums,
     int session_id,
     string userName,
     string password,
     String curDir)
 {
     CommandLineUtil.run_exe(files, enums, session_id, userName, password, curDir);
 }
        /// <summary>
        ///     Gets a value specified on the command line, in the form "+key" "value"
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="configKey">The name of the key, without the leading +, e.g. "key"</param>
        /// <returns>The value of the key</returns>
        /// <exception cref="Exception">Thrown when the value of the given configuration is not found.</exception>
        public T GetCommandLineValue<T>(string configKey)
        {
            T configValue;
            if (CommandLineUtil.TryGetConfigValue(commandLineDictionary, configKey, out configValue))
            {
                return configValue;
            }

            throw new Exception(string.Format("Could not find the configuration value for '{0}'.", configKey));
        }
Exemplo n.º 19
0
 private static int ParseArguments(string[] args)
 {
     if (!CommandLineUtil.ParseArg(args, "d", out directories))
     {
         ShowError("Missing the directories parameter (-d)");
         return(7);
     }
     if (!CommandLineUtil.ParseArg(args, "f", out filemask))
     {
         filemask = "*.*";
     }
     return(0);
 }
        /// <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);
        }
Exemplo n.º 21
0
        public static void Start(string[] arguments)
        {
            arguments = CommandLineUtil.SplitCombinedOptions(arguments);
            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.StartBot)
            {
                ProcessStartBot();
            }
            else if (option.StartServer)
            {
                ProcessStartServer();
            }
            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 './NotiServer --help' to get more information");
            }

            return;
        }
Exemplo n.º 22
0
        internal string GetSpatialPath()
        {
            string path;

            // The command line overrides everything.
            if (!CommandLineUtil.TryGetCommandLineValue(GetCommandLine(), SpatialPathArgument, out path))
            {
                // Then try the user-specific preferences
                path = GetUserString(SpatialRunner.CommandLocationKey, string.Empty);
            }

            // If nothing has been configured, assume it's on the system PATH, and use a sensible default of "spatial"
            if (string.IsNullOrEmpty(path))
            {
                path = DiscoverSpatialLocation(null);
            }

            return(path);
        }
Exemplo n.º 23
0
        public string[] GetUnityCommandline()
        {
            var unityPathData = myFrontendBackendModel.UnityApplicationData;

            if (!unityPathData.HasValue())
            {
                return(null);
            }
            var unityPath = unityPathData.Value?.ApplicationPath;

            if (unityPath != null && PlatformUtil.RuntimePlatform == PlatformUtil.Platform.MacOsX)
            {
                unityPath = FileSystemPath.Parse(unityPath).Combine("Contents/MacOS/Unity").FullPath;
            }

            return(unityPath == null
                ? null
                : new[] { unityPath, "-projectPath", CommandLineUtil.QuoteIfNeeded(mySolution.SolutionDirectory.FullPath) });
        }
Exemplo n.º 24
0
        public void TestYesNoToBool()
        {
            Assert.AreEqual(true, CommandLineUtil.ParseYesNo(null, true));
            Assert.AreEqual(false, CommandLineUtil.ParseYesNo(null, false));
            Assert.AreEqual(true, CommandLineUtil.ParseYesNo("", true));
            Assert.AreEqual(false, CommandLineUtil.ParseYesNo("", false));

            Assert.AreEqual(true, CommandLineUtil.ParseYesNo("y", false));
            Assert.AreEqual(true, CommandLineUtil.ParseYesNo("y", true));
            Assert.AreEqual(false, CommandLineUtil.ParseYesNo("ye", false));
            Assert.AreEqual(true, CommandLineUtil.ParseYesNo("yes", true));
            Assert.AreEqual(false, CommandLineUtil.ParseYesNo("yex", false));
            Assert.AreEqual(true, CommandLineUtil.ParseYesNo("yesx", true));

            Assert.AreEqual(false, CommandLineUtil.ParseYesNo("n", false));
            //Assert.AreEqual(false, CommandLineUtil.ParseYesNo("n", true));
            //Assert.AreEqual(false, CommandLineUtil.ParseYesNo("no", false));
            //Assert.AreEqual(false, CommandLineUtil.ParseYesNo("no", true));
            //Assert.AreEqual(false, CommandLineUtil.ParseYesNo("nox", false));
            //Assert.AreEqual(true, CommandLineUtil.ParseYesNo("nox", true));
        }
    public string compileClass
        (string library_path,
        string moduleName,
        Tuple <string, string>[] sourceContents,
        string[] references,
        int outFile,
        string userName,
        string password,
        string curDir)
    {
        string publicKeyToken = null;

        //creates the strong key, for new assembly
        publicKeyToken = CommandLineUtil.create_strong_key(moduleName, userName, password, curDir);
        //compile, generate dll
        CommandLineUtil.compile_source(sourceContents, moduleName, references, userName, password, curDir);
        //installing on local GAC
        CommandLineUtil.gacutil_install(library_path, moduleName, 1, userName, password);

        return(publicKeyToken);
    }
Exemplo n.º 26
0
        /// <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);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Create keystore file
        /// </summary>
        /// <param name="parameters">
        /// Parameters Index
        /// </param>
        /// <returns></returns>
        public static bool RegisterWallet(string command, string[] parameters)
        {
            string[] usage = new string[] {
                string.Format("{0} [command option] <path>\n", command)
            };

            string[] command_option = new string[] { HelpCommandOption.Help };

            if (parameters != null)
            {
                OutputHelpMessage(usage, null, command_option, null);
                return(true);
            }

            try
            {
                string password = CommandLineUtil.ReadPasswordString("Please input wallet password");
                string confirm  = CommandLineUtil.ReadPasswordString("Please input confirm wallet password");

                if (!password.Equals(confirm))
                {
                    Console.WriteLine("Confirm password does not match");
                    return(true);
                }

                RpcApiResult result = RpcApi.RegisterWallet(password);
                Logout(null, null);

                OutputResultMessage(command, result.Result, result.Code, result.Message);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
            }


            return(true);
        }
Exemplo n.º 28
0
        public static RpcApiResult SignatureTransaction(ref Transaction transaction)
        {
            if (transaction.RawData.Timestamp == 0)
            {
                transaction.RawData.Timestamp = Helper.CurrentTimeMillis();
            }

            ProtocolUtil.SetExpirationTime(ref transaction);
            Console.WriteLine("Your transaction details are as follows, please confirm.");
            Console.WriteLine("transaction hex string is " + transaction.ToByteArray().ToHexString());
            Console.WriteLine(PrintUtil.PrintTransaction(transaction));
            Console.WriteLine(
                "Please confirm and input your permission id, if input y or Y means default 0, other non-numeric characters will cancell transaction.");
            ProtocolUtil.SetPermissionId(ref transaction);

            try
            {
                while (true)
                {
                    Console.WriteLine("Please choose keystore for signature.");
                    KeyStore key_store = SelectKeyStore();

                    string password = CommandLineUtil.ReadPasswordString("Please input password");
                    if (KeyStoreService.DecryptKeyStore(password, key_store, out byte[] privatekey))
Exemplo n.º 29
0
        public static void Start(string[] arguments)
        {
            arguments = CommandLineUtil.SplitCombinedOptions(arguments);
            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.RelatedTagTest != null)
            {
                ProcessRelatedTagTest(option.RelatedTagTest);
            }
            else if (option.CharacterTest != null)
            {
                ProcessCharacterTest(option.CharacterTest);
            }
            else if (option.SeriesTest != null)
            {
                ProcessSeriesTest(option.SeriesTest);
            }
            else if (option.Start)
            {
                ProcessStart(option.IncludeExHetaiData, option.LowPerf, option.SyncOnly, option.UseServer, option.UseElasticSearch,
                             option.HitomiSyncRange, option.HitomiSyncLookupRange, option.ExHentaiLookupPage, option.SyncOnlyHitomi);
            }
            else if (option.Compress)
            {
                ProcessCompress(option.IncludeExHetaiData, option.LowPerf);
            }
            else if (option.CreateEHentaiInverseTable)
            {
                ProcessCreateEHentaiInverseTable(option.LowPerf);
            }
            else if (option.CreateDateTimeEstimator)
            {
                ProcessCreateDateTimeEstimator(option.LowPerf);
            }
            else if (option.InitServer)
            {
                ProcessInitServer(null);
            }
            else if (option.InitServerPages)
            {
                ProcessInitServerPages(null);
            }
            else if (option.ExportForDBRange != null)
            {
                ProcessExportForDBRange(option.ExportForDBRange);
            }
            else if (option.SaveExhentaiPage != null)
            {
                ProcessSaveExhentaiPage(option.SaveExhentaiPage);
            }
            else if (option.ExportForES)
            {
                ProcessExportToES(null);
            }
            else if (option.ExportForESRange != null)
            {
                ProcessExportForESRange(option.ExportForESRange);
            }
            else if (option.Test != null)
            {
                ProcessTest(option.Test);
            }
            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;
        }
Exemplo n.º 30
0
 public void SetUp()
 {
     _commandLineUtil = new CommandLineUtil();
 }
        static int Main(string[] args)
        {
            try
            {

                // Handles a bug in .NET console applications
                var handle = Process.GetCurrentProcess().MainWindowHandle;
                SetConsoleMode(handle, ENABLE_EXTENDED_FLAGS);

                // Get the version number
                var assembly = Assembly.GetExecutingAssembly();
                var assemblyVersion = assembly.GetName().Version.ToString();

                Console.WriteLine("CrossLinkingIMS Console Application Version " + assemblyVersion);

                var commandLineUtil = new CommandLineUtil(caseSensitiveSwitchNames: false);

                // Make sure we have parameters. If not, then show the user the proper syntax
                var doParametersExist = commandLineUtil.ParseCommandLine();
                if (!doParametersExist)
                {
                    ShowSyntax();
                    return -1;
                }

                // Get the Feature File Location
                string featureFileLocation;
                if (!commandLineUtil.RetrieveValueForParameter("f", out featureFileLocation))
                {
                    Console.WriteLine("-f switch is missing");
                    ShowSyntax();
                    return -2;
                }

                if (!FileExists(featureFileLocation))
                {
                    return -4;
                }

                var featureFile = new FileInfo(featureFileLocation);

                // Get the Peaks File Location
                string peaksFileLocation;
                if (!commandLineUtil.RetrieveValueForParameter("p", out peaksFileLocation))
                {
                    Console.WriteLine("-p switch is missing");
                    ShowSyntax();
                    return -2;
                }

                if (!FileExists(peaksFileLocation))
                {
                    return -4;
                }

                var peaksFile = new FileInfo(peaksFileLocation);

                // Get the FastA File Location
                string fastAFileLocation;
                if (!commandLineUtil.RetrieveValueForParameter("fasta", out fastAFileLocation))
                {
                    Console.WriteLine("-fasta switch is missing");
                    ShowSyntax();
                    return -2;
                }

                if (!FileExists(fastAFileLocation))
                {
                    return -4;
                }

                var fastAFile = new FileInfo(fastAFileLocation);

                // Get the PPM Mass Tolerance
                string massToleranceString;
                if (!commandLineUtil.RetrieveValueForParameter("ppm", out massToleranceString))
                {
                    Console.WriteLine("-ppm switch is missing");
                    ShowSyntax();
                    return -2;
                }

                var massTolerance = double.Parse(massToleranceString);

                // Get the Max Missed Cleavages
                string maxMissedCleavagesString;
                commandLineUtil.RetrieveValueForParameter("c", out maxMissedCleavagesString);

                if (string.IsNullOrEmpty(maxMissedCleavagesString))
                    maxMissedCleavagesString = "1";

                var maxMissedCleavages = int.Parse(maxMissedCleavagesString);

                // Get the Partially Tryptic Flag
                string trypticString;
                commandLineUtil.RetrieveValueForParameter("t", out trypticString);

                string staticDeltaMassString;
                var staticDeltaMass = 0.0;
                if (commandLineUtil.RetrieveValueForParameter("static", out staticDeltaMassString))
                {
                    double.TryParse(staticDeltaMassString, out staticDeltaMass);
                }

                var useC13 = true;
                var useN15 = true;

                if (commandLineUtil.IsParameterPresent("c13off"))
                    useC13 = false;

                if (commandLineUtil.IsParameterPresent("n15off"))
                    useN15 = false;

                if (!(useC13 || useN15) && Math.Abs(staticDeltaMass) < float.Epsilon)
                {
                    Console.WriteLine("If you use both -C13off and -N15off, you must use -Static:MassDiff to specify a static mass difference");
                    Thread.Sleep(1500);
                    return -3;
                }

                var settings = new CrossLinkSettings(massTolerance, maxMissedCleavages, trypticString, useC13, useN15, staticDeltaMass);

                // Get the Output File Location
                string outputFileLocation;
                if (!commandLineUtil.RetrieveValueForParameter("o", out outputFileLocation))
                {
                    if (featureFile.DirectoryName != null && featureFile.DirectoryName == peaksFile.DirectoryName)
                        outputFileLocation = Path.Combine(featureFile.DirectoryName, "crossLinkResults.csv");
                    else
                        outputFileLocation = "crossLinkResults.csv";
                }

                // Run the cross-linking application
                Console.WriteLine("Executing...");
                var crossLinkResults = CrossLinkingImsController.Execute(settings, fastAFile, featureFile, peaksFile);

                var outputFileInfo = new FileInfo(outputFileLocation);

                // Output the results
                Console.WriteLine("Outputting " + crossLinkResults.Count().ToString("#,##0") + " results to \n" + outputFileInfo.FullName);
                CrossLinkUtil.OutputCrossLinkResults(crossLinkResults, outputFileInfo);

                return 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine("=========================================");
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine("=========================================");

                Thread.Sleep(2000);
                return -10;
            }
        }