/// <summary> /// Runs a command line with ML.Net. /// </summary> /// <param name="script">script to run</param> /// <param name="catch_output">capture output</param> /// <param name="env">delegate environment</param> /// <returns>output and error if captured</returns> public static string MamlScript(string script, bool catch_output, DelegateEnvironment env = null) { int errCode; string res; if (catch_output) { using (var capture = new StdCapture()) { errCode = DocumentationEnvironmentHelper.MainWithProgress(script, env); var sout = capture.StdOut; var serr = capture.StdErr; if (string.IsNullOrEmpty(serr)) { res = sout; } else { res = $"--OUT--\n{sout}\n--ERR--\n{serr}"; } } } else { errCode = DocumentationEnvironmentHelper.MainWithProgress(script, env); res = string.Empty; } if (errCode != 0) { throw new MamlException($"Unable to run script, error code={errCode}\n{script}" + (string.IsNullOrEmpty(res) ? string.Empty : $"\n{res}")); } return(res); }
public void TestCSGeneratorHelp() { var cmd = "? CSGenerator"; using (var std = new Scikit.ML.DocHelperMlExt.StdCapture()) { Maml.MainAll(cmd); if (std.StdOut.Length == 0) { Assert.Inconclusive("Not accurate on a remote machine."); } } }