Ejemplo n.º 1
0
        public static AppBehavior Create(CmdLineHelper helper)
        {
            var codepath = helper.Next();
            var output   = helper.Next();
            var makeBin  = helper.Next();

            if (output == null || codepath == null)
            {
                return(null);
            }

            var appMaker = new MakeAppBehavior(codepath, output);

            if (makeBin != null && makeBin == "-bin")
            {
                appMaker.CreateDumpOnly = true;
            }

            return(appMaker);
        }
Ejemplo n.º 2
0
        private static AppBehavior SelectParametrized(CmdLineHelper helper)
        {
            var param = helper.Current().ToLowerInvariant();

            if (param == "-measure")
            {
                var path = helper.Next();
                if (path != null)
                {
                    return(new MeasureBehavior(path, helper.Tail()));
                }
            }
            else if (param == "-compile")
            {
                var path = helper.Next();
                if (path != null)
                {
                    return(new ShowCompiledBehavior(path));
                }
            }
            else if (param == "-check")
            {
                return(ProcessCheckKey(helper));
            }
            else if (param == "-make")
            {
                var codepath = helper.Next();
                var output   = helper.Next();
                var makeBin  = helper.Next();
                if (output != null && codepath != null)
                {
                    var appMaker = new MakeAppBehavior(codepath, output);
                    if (makeBin != null && makeBin == "-bin")
                    {
                        appMaker.CreateDumpOnly = true;
                    }

                    return(appMaker);
                }
            }
            else if (param == "-cgi")
            {
                return(new CgiBehavior());
            }
            else if (param == "-version" || param == "-v")
            {
                return(new ShowVersionBehavior());
            }
            else if (param.StartsWith("-encoding="))
            {
                return(ProcessEncodingKey(helper));
            }
            else if (param.StartsWith("-codestat="))
            {
                var prefixLen = ("-codestat=").Length;
                if (param.Length > prefixLen)
                {
                    var outputStatFile = param.Substring(prefixLen);
                    ScriptFileHelper.EnableCodeStatistics(outputStatFile);
                    return(Select(helper.Tail()));
                }
            }
            else if (param == "-debug")
            {
                var arg  = helper.Next();
                int port = 2801;
                if (arg != null && arg.StartsWith("-port="))
                {
                    var prefixLen = ("-port=").Length;
                    if (arg.Length > prefixLen)
                    {
                        var value = arg.Substring(prefixLen);
                        if (!Int32.TryParse(value, out port))
                        {
                            Output.WriteLine("Incorrect port: " + value);
                            return(null);
                        }
                    }
                }
                else if (arg != null)
                {
                    var path = arg;
                    return(new DebugBehavior(port, path, helper.Tail()));
                }
            }
            else if (param == "-serialize")
            {
                var path = helper.Next();
                if (path != null)
                {
                    return(new SerializeModuleBehavior(path));
                }

                return(new ShowUsageBehavior());
            }

            return(null);
        }