public static AppBehavior Create(CmdLineHelper helper) { if (helper.Next() == null) { return(null); } bool cgiMode = false; var arg = helper.Current(); if (arg.ToLowerInvariant() == "-cgi") { cgiMode = true; arg = helper.Next(); } var path = arg; var env = helper.Next(); if (env != null && env.StartsWith("-env=")) { env = env.Substring(5); } return(new CheckSyntaxBehavior(path, env, cgiMode)); }
public static AppBehavior Select(string[] cmdLineArgs) { var helper = new CmdLineHelper(cmdLineArgs); string arg = helper.Next(); if (arg == null) { return(new ShowUsageBehavior()); } if (!arg.StartsWith("-")) { var path = arg; return(new ExecuteScriptBehavior(path, helper.Tail())); } var selected = SelectParametrized(helper); if (selected == null) { selected = new ShowUsageBehavior(); } return(selected); }
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); }
public static AppBehavior Create(CmdLineHelper helper) { var path = helper.Next(); if (path != null) { return(new SerializeModuleBehavior(path)); } return(new ShowUsageBehavior()); }
public static AppBehavior Create(CmdLineHelper helper) { int port = 2801; string path = null; DebugProtocolType protocolType = DebugProtocolType.Tcp; while (true) { var arg = helper.Next(); if (arg == null) { break; } var parsedArg = helper.Parse(arg); if (parsedArg.Name == "-port") { var portString = parsedArg.Value; if (string.IsNullOrEmpty(portString)) { return(null); } if (!Int32.TryParse(portString, out port)) { Output.WriteLine("Incorrect port: " + portString); return(null); } } else if (parsedArg.Name == "-protocol") { var proto = parsedArg.Value; if (string.IsNullOrEmpty(proto) || !Enum.TryParse(proto, true, out protocolType)) { Output.WriteLine("Unknown protocol. Using default"); protocolType = DebugProtocolType.Tcp; } } else { path = arg; break; } } return(path == null ? null : new DebugBehavior(port, path, helper.Tail()) { ProtocolType = protocolType }); }
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); }
public static AppBehavior Create(CmdLineHelper helper) { var path = helper.Next(); return(path != null ? new ShowCompiledBehavior(path) : null); }
public static AppBehavior Create(CmdLineHelper helper) { var path = helper.Next(); return(path != null ? new MeasureBehavior(path, helper.Tail()) : null); }