Example #1
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);
        }
Example #2
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;
		}
Example #3
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;
	        }
        }
Example #4
0
        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);
            }
        }