コード例 #1
0
 private static void ExecuteInteractive()
 {
     while (true)
     {
         Console.Write("Host: ");
         var host = Console.ReadLine();
         if (string.IsNullOrWhiteSpace(host))
         {
             Console.WriteLine("хост указан неверно!");
             continue;
         }
         Console.Write("App: ");
         var app = Console.ReadLine();
         if (string.IsNullOrWhiteSpace(app))
         {
             Console.WriteLine("приложение указано неверно!");
             continue;
         }
         Console.Write("User: "******"пользователь указан неверно!");
             continue;
         }
         var password = new ConsoleArgumentHelper().ReadLineSafety("Password: "******"пароль указан неверно!");
             continue;
         }
         Console.WriteLine();
         Execute(host, app, user, password);
     }
 }
コード例 #2
0
        static int Main(string[] args)
        {
            var argsdict = new ConsoleArgumentHelper().ParseDictionary(args);

            if (argsdict.ContainsKey("arg1"))
            {
                filename = argsdict["arg1"];
            }
            if (argsdict.ContainsKey("nolex"))
            {
                opts |= BxlParserOptions.NoLexData;
            }
            if (argsdict.ContainsKey("tofile"))
            {
                useoutfile = true;
            }
            if (string.IsNullOrWhiteSpace(filename))
            {
                useoutfile = true;
            }
            string[] files;
            if (!string.IsNullOrWhiteSpace(filename))
            {
                files = new[] { filename };
            }
            else
            {
                files = Directory.GetFiles(Environment.CurrentDirectory, "*.bxl", SearchOption.AllDirectories);
            }
            foreach (var file in files)
            {
                Execute(file);
            }
            return(0);
        }
コード例 #3
0
        /// <summary>
        ///     Executes manifest generator
        /// </summary>
        /// <param name="args"> </param>
        public void Run(string[] args)
        {
            var options = new ConsoleArgumentHelper().Parse <ManifestBxlGeneratorOptions>(args);

            if (options.LibraryDirectory.IsEmpty() && options.LibraryName.IsNotEmpty())
            {
                options.LibraryDirectory = Path.GetDirectoryName(Path.GetFullPath(options.LibraryName));
                options.LibraryName      = Path.GetFileName(options.LibraryName);
            }
            options.LibraryDirectory = Path.GetFullPath(options.LibraryDirectory);
            if (options.LibraryName.IsNotEmpty())
            {
                options.LibraryName = Path.Combine(options.LibraryDirectory, options.LibraryName);
            }
            if (options.OutputFile.IsNotEmpty())
            {
                Console.WriteLine("LibraryDir: " + options.LibraryDirectory);
            }
            var generator = new ManifestBxlGenerator();
            var content   = generator.GenerateManifest(options);

            if (options.OutputFile.IsEmpty())
            {
                Console.WriteLine(content);
            }
            else
            {
                if (content.IsEmpty() && options.LibraryName.IsNotEmpty())
                {
                    return;
                }
                File.WriteAllText(options.OutputFile, content);
                Console.WriteLine("manifest saved");
            }
        }
コード例 #4
0
        public void Setup()
        {
            var args = new[] { "p1", "p2", "--x", "XVAL", "--y-p", "YVAL", "--b", "--c", "--u", "A", "B", "C" };

            _dict  = new ConsoleArgumentHelper().ParseDictionary(args);
            _targs = new ConsoleArgumentHelper().Parse <TestArgs>(args);
        }
コード例 #5
0
        /// <summary>
        /// </summary>
        /// <param name="args"> </param>
        /// <returns> </returns>
        public static int Main(string[] args)
        {
            var application = new DslConsoleApplication();
            var arguments   = new ConsoleArgumentHelper().Parse <DslBuilderArgs>(args);
            var result      = application.Run(arguments);

            foreach (var dslMessage in result.Messages)
            {
                if (dslMessage.ErrorLevel >= ErrorLevel.Warning)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                if (dslMessage.ErrorLevel >= ErrorLevel.Error)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                Console.WriteLine(dslMessage);

                Console.ResetColor();
            }
            if (result.MaxLevel >= ErrorLevel.Error)
            {
                return(-1);
            }
            return(0);
        }
コード例 #6
0
    private static void SetTestsNamespacesFromCommandLineArgument()
    {
        string namespaceString = ConsoleArgumentHelper.GetArg("-testNamespaces");

        int timeScale = 0;

        if (!string.IsNullOrEmpty(namespaceString))
        {
            namespaceString = namespaceString.Replace(" ", String.Empty);
            string[] strings = namespaceString.Split(';');

            if (strings.Length > 0)
            {
                PlayModeTestRunner.Namespaces = strings.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                if (PlayModeTestRunner.Namespaces.Length > 0)
                {
                    Debug.LogFormat("TestTools: namespace string {0}  Test Namespaces count: {1}",
                                    namespaceString,
                                    PlayModeTestRunner.Namespaces.Length);

                    foreach (var name in PlayModeTestRunner.Namespaces)
                    {
                        Debug.Log("namespace: " + name);
                    }
                    return;
                }
            }
        }

        Debug.Log("TestTools: No Test Namespaces:");
        PlayModeTestRunner.Namespaces = null;
    }
コード例 #7
0
    private static void ResolveTestMode()
    {
        bool runOnlySelected = ConsoleArgumentHelper.IsArgExist("-runOnlySelectedTests");
        bool runOnlySmoke    = ConsoleArgumentHelper.IsArgExist("-runOnlySmokeTests");

        ResolveTestMode(runOnlySelected, runOnlySmoke);
    }
コード例 #8
0
        static int Main(string[] args) {
	        try{
		        if (null != args && 0 != args.Length){
			        var wdir = Array.IndexOf(args, "--workdir");
			        if (-1 != wdir){
				        Environment.CurrentDirectory = Path.GetFullPath(args[wdir + 1]);
			        }
		        }

		        var builder = new BSharpBuilder();
		        var adict = new ConsoleArgumentHelper().ParseDictionary(args);
		        if (adict.ContainsKey("debug")){
			        Debugger.Launch();
		        }
		        var log = SetupLog(adict);
		        var project = SetupProject(adict, log, builder);
		        builder.Log = log;
		        builder.Initialize(project);
		        var resultContext = builder.Build();
		        WriteOutErrors(resultContext, log);
		        return 0;
	        }
	        catch (Exception ex){
		        Console.Error.WriteLine(ex.ToString());
		        return -1;
	        }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Qorpent/qorpent.sys
 private static void ExecuteInteractive() {
     while (true) {
         Console.Write("Host: ");
         var host = Console.ReadLine();
         if (string.IsNullOrWhiteSpace(host)) {
             Console.WriteLine("хост указан неверно!");
             continue;
         }
         Console.Write("App: ");
         var app = Console.ReadLine();
         if (string.IsNullOrWhiteSpace(app))
         {
             Console.WriteLine("приложение указано неверно!");
             continue;
         }
         Console.Write("User: "******"пользователь указан неверно!");
             continue;
         }
         var password = new ConsoleArgumentHelper().ReadLineSafety("Password: "******"пароль указан неверно!");
             continue;
         }
         Console.WriteLine();
         Execute(host, app, user, password);
     }
    
 }
コード例 #10
0
		/// <summary>
		/// 	Executes manifest generator
		/// </summary>
		/// <param name="args"> </param>
		public void Run(string[] args) {
			var options = new ConsoleArgumentHelper().Parse<ManifestBxlGeneratorOptions>(args);
			if (options.LibraryDirectory.IsEmpty() && options.LibraryName.IsNotEmpty()) {
				options.LibraryDirectory = Path.GetDirectoryName(Path.GetFullPath(options.LibraryName));
				options.LibraryName = Path.GetFileName(options.LibraryName);
			}
			options.LibraryDirectory = Path.GetFullPath(options.LibraryDirectory);
			if (options.LibraryName.IsNotEmpty()) {
				options.LibraryName = Path.Combine(options.LibraryDirectory, options.LibraryName);
			}
			if (options.OutputFile.IsNotEmpty()) {
				Console.WriteLine("LibraryDir: " + options.LibraryDirectory);
			}
			var generator = new ManifestBxlGenerator();
			var content = generator.GenerateManifest(options);
			if (options.OutputFile.IsEmpty()) {
				Console.WriteLine(content);
			}
			else {
				if (content.IsEmpty() && options.LibraryName.IsNotEmpty()) {
					return;
				}
				File.WriteAllText(options.OutputFile, content);
				Console.WriteLine("manifest saved");
			}
		}
コード例 #11
0
        static int Main(string[] args)
        {
            if (args.Contains("--debug"))
            {
                Debugger.Launch();
            }
            var dict = new ConsoleArgumentHelper().ParseDictionary(args);

            var outstring   = dict.SafeGet("out", "hello");
            var errorstring = dict.SafeGet("error", "");
            var state       = dict.SafeGet("state", 0);
            var throwex     = dict.SafeGet("throwex", false);
            var doreadln    = dict.SafeGet("doreadln", false);
            var timeout     = dict.SafeGet("timeout", 0);
            var interactive = dict.SafeGet("interactive", false);
            var passread    = dict.SafeGet("passread", false);

            if (!string.IsNullOrWhiteSpace(outstring))
            {
                Console.Out.WriteLine(outstring);
                Console.Out.Flush();
            }
            if (doreadln)
            {
                Console.WriteLine(Console.ReadLine());
            }

            if (interactive)
            {
                Console.WriteLine("a");
                var fst = Console.ReadLine();
                Console.WriteLine("b");
                var sec = Console.ReadLine();
                Console.WriteLine(fst.ToInt() + sec.ToInt());
            }

            if (passread)
            {
                Console.Write("Enter login: "******"Password: "******"/{0}:{1}/", user, pass);
            }

            if (!string.IsNullOrWhiteSpace(errorstring))
            {
                Console.Error.WriteLine(errorstring);
            }
            if (timeout != 0)
            {
                Thread.Sleep(timeout * 1000);
            }
            if (throwex)
            {
                throw new Exception("some error");
            }

            return(state);
        }
コード例 #12
0
        public void ShortCutParametersTest()
        {
            var dict = new ConsoleArgumentHelper().ParseDictionary(new[] { "-x", "a", "-y", "-z" });

            Assert.AreEqual("1", dict["~z"]);
            Assert.AreEqual("1", dict["~y"]);
            Assert.AreEqual("a", dict["~x"]);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: Qorpent/qorpent.sys
 private static void ExecuteNonInteractive(string[] args) {
     var cah = new ConsoleArgumentHelper();
     var dict = cah.ParseDictionary(args);
     if(!dict.ContainsKey("host") || string.IsNullOrWhiteSpace(dict["host"]))throw new ArgumentException("no host provided");
     if(!dict.ContainsKey("app") || string.IsNullOrWhiteSpace(dict["app"]))throw new ArgumentException("no app provided");
     if(!dict.ContainsKey("user") || string.IsNullOrWhiteSpace(dict["user"]))throw new ArgumentException("no user provided");
     if(!dict.ContainsKey("password") || string.IsNullOrWhiteSpace(dict["password"]))throw new ArgumentException("no password provided");
     Execute(dict["host"],dict["app"],dict["user"],dict["password"]);
 }
コード例 #14
0
    private static void TestBuild()
    {
        SetTimeScaleFromCommandLineArgument();
        PrepareBuild();

        string[] list = EditorBuildSettings.scenes.Where(x => x.enabled).Select(x => x.path).ToArray();
        BuildPipeline.BuildPlayer(list,
                                  ConsoleArgumentHelper.GetArg("-testBuildPath"), BuildTarget.Android,
                                  BuildOptions.None);
    }
コード例 #15
0
		private static HostConfig PrepareHostConfig(string[] args)
		{
			var cfg = new HostConfig();
			cfg.ApplicationMode = HostApplicationMode.Standalone;
			var argdicts = new ConsoleArgumentHelper().ParseDictionary(args);
			if (argdicts.ContainsKey("config"))
			{
				var configFile = argdicts["config"];
				XElement configXml = null;
				if (configFile.EndsWith(".xml"))
				{
					configXml = XElement.Load(configFile);
				}
				else
				{
					configXml = new BxlParser().Parse(File.ReadAllText(configFile), configFile);
				}
				cfg.LoadXmlConfig(configXml);
			}
			if (argdicts.ContainsKey("root"))
			{
				cfg.RootFolder = Path.GetFullPath(argdicts["root"]);
			}
			if (cfg.Bindings.Count == 0)
			{
				cfg.AddDefaultBinding();
			}

			if (argdicts.ContainsKey("port")){
				cfg.Bindings[0].Port = argdicts["port"].ToInt();

			}

			if (argdicts.ContainsKey("content")){
				var folders = argdicts["content"].SmartSplit(false, true, ';');
				foreach (var folder in folders){
					cfg.ContentFolders.Add(folder);	
				}

				
			}

			if (argdicts.ContainsKey("appname"))
			{
				foreach (var hostBinding in cfg.Bindings)
				{
					if (hostBinding.AppName == "/")
					{
						hostBinding.AppName = argdicts["appname"];
					}
				}
			}
			return cfg;
		}
コード例 #16
0
ファイル: Program.cs プロジェクト: Qorpent/qorpent.sys
        static int Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            try{
                if (null != args && 0 != args.Length)
                {
                    var wdir = Array.IndexOf(args, "--workdir");
                    if (-1 != wdir)
                    {
                        Environment.CurrentDirectory = Path.GetFullPath(args[wdir + 1]);
                    }
                }
                ConsoleMode = args.Contains("--console-mode");
                var builder = new BSharpBuilder();
                var adict   = new ConsoleArgumentHelper().ParseDictionary(args);
                if (adict.ContainsKey("debug"))
                {
                    Debugger.Launch();
                }
                var  log   = SetupLog(adict);
                bool watch = args.Contains("--watch");

                var project = DoBuild(adict, log, builder, watch);
                if (watch)
                {
                    var laststamp = GetStamp(project);
                    Console.WriteLine("----------------------------------------------");
                    while (true)
                    {
                        Thread.Sleep(2000);
                        var newstamp = GetStamp(project);
                        if (newstamp > laststamp)
                        {
                            project   = DoBuild(adict, log, new BSharpBuilder(), true);
                            laststamp = newstamp;
                            Console.WriteLine("----------------------------------------------");
                        }
                    }
                }
                return(0);
            }
            catch (Exception ex) {
                if (ConsoleMode)
                {
                    Console.Error.WriteLine(new XElement("generic-error", ex.ToString()).ToString());
                }
                else
                {
                    Console.Error.WriteLine(ex.ToString());
                }
                return(-1);
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: comdiv/qorpent.sys.tools
		/// <summary>
		/// 	main method for Executable
		/// </summary>
		/// <param name="args"> </param>
		/// <returns> </returns>
		public static int Main(string[] args) {
			try {
				var strongTypedArguments = new ConsoleArgumentHelper().Parse<SqlInstallerConsoleProgramArgs>(args);
				return new SqlInstallerConsoleProgram().Run(strongTypedArguments);
			}
			catch (Exception ex) {
				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine(ex.ToString());
				Console.ResetColor();
				return -1;
			}
		}
コード例 #18
0
ファイル: Program.cs プロジェクト: Qorpent/qorpent.sys
		static int Main(string[] args){
            if (args.Contains("--debug"))
            {
                Debugger.Launch();
            }
			var dict = new ConsoleArgumentHelper().ParseDictionary(args);

			var outstring = dict.SafeGet("out", "hello");
			var errorstring = dict.SafeGet("error", "");
			var state = dict.SafeGet("state", 0);
			var throwex = dict.SafeGet("throwex", false);
			var doreadln = dict.SafeGet("doreadln", false);
			var timeout = dict.SafeGet("timeout", 0);
			var interactive = dict.SafeGet("interactive", false);
			var passread = dict.SafeGet("passread", false);
			
			if (!string.IsNullOrWhiteSpace(outstring)){
				Console.Out.WriteLine(outstring);
                Console.Out.Flush();
			}
			if (doreadln){
				Console.WriteLine(Console.ReadLine());
			}

			if (interactive){
				Console.WriteLine("a");
				var fst = Console.ReadLine();
				Console.WriteLine("b");
				var sec = Console.ReadLine();
				Console.WriteLine(fst.ToInt()+sec.ToInt());
			}

			if (passread){
				Console.Write("Enter login: "******"Password: "******"/{0}:{1}/",user,pass);

			}

			if (!string.IsNullOrWhiteSpace(errorstring)){
				Console.Error.WriteLine(errorstring);	
			}
			if (timeout!=0){
				Thread.Sleep(timeout*1000);
			}
			if (throwex){
				throw new Exception("some error");
			}

			return state;
		}
コード例 #19
0
 /// <summary>
 ///     main method for Executable
 /// </summary>
 /// <param name="args"> </param>
 /// <returns> </returns>
 public static int Main(string[] args)
 {
     try {
         var strongTypedArguments = new ConsoleArgumentHelper().Parse <SqlInstallerConsoleProgramArgs>(args);
         return(new SqlInstallerConsoleProgram().Run(strongTypedArguments));
     }
     catch (Exception ex) {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(ex.ToString());
         Console.ResetColor();
         return(-1);
     }
 }
コード例 #20
0
    private static void SetTimeScaleFromCommandLineArgument()
    {
        string timeScaleString = ConsoleArgumentHelper.GetArg("-timeScale");

        int timeScale = 0;

        if (timeScaleString != null)
        {
            int.TryParse(timeScaleString, out timeScale);
        }
        if (timeScale <= 0)
        {
            timeScale = 1;
        }
        PlayModeTestRunner.DefaultTimescale = timeScale;
    }
コード例 #21
0
ファイル: Program.cs プロジェクト: comdiv/qorpent.sys.tools
		/// <summary>
		/// </summary>
		/// <param name="args"> </param>
		/// <returns> </returns>
		public static int Main(string[] args) {
			var application = new DslConsoleApplication();
			var arguments = new ConsoleArgumentHelper().Parse<DslBuilderArgs>(args);
			var result = application.Run(arguments);
			foreach (var dslMessage in result.Messages) {
				if (dslMessage.ErrorLevel >= ErrorLevel.Warning) {
					Console.ForegroundColor = ConsoleColor.Yellow;
				}
				if (dslMessage.ErrorLevel >= ErrorLevel.Error) {
					Console.ForegroundColor = ConsoleColor.Red;
				}
				Console.WriteLine(dslMessage);

				Console.ResetColor();
			}
			if (result.MaxLevel >= ErrorLevel.Error) {
				return -1;
			}
			return 0;
		}
コード例 #22
0
        private static void ExecuteNonInteractive(string[] args)
        {
            var cah  = new ConsoleArgumentHelper();
            var dict = cah.ParseDictionary(args);

            if (!dict.ContainsKey("host") || string.IsNullOrWhiteSpace(dict["host"]))
            {
                throw new ArgumentException("no host provided");
            }
            if (!dict.ContainsKey("app") || string.IsNullOrWhiteSpace(dict["app"]))
            {
                throw new ArgumentException("no app provided");
            }
            if (!dict.ContainsKey("user") || string.IsNullOrWhiteSpace(dict["user"]))
            {
                throw new ArgumentException("no user provided");
            }
            if (!dict.ContainsKey("password") || string.IsNullOrWhiteSpace(dict["password"]))
            {
                throw new ArgumentException("no password provided");
            }
            Execute(dict["host"], dict["app"], dict["user"], dict["password"]);
        }
コード例 #23
0
        public void Q305_Nagative_Numbers()
        {
            var dict = new ConsoleArgumentHelper().ParseDictionary(new[] { "-x", "-1" });

            Assert.AreEqual("-1", dict["~x"]);
        }