protected override Task Run(ArgAction toRun) { ConsoleOutInterceptor.Instance.Attach(); toRun.Invoke(); var output = ConsoleOutInterceptor.Instance.ReadAndClear(); ConsoleOutInterceptor.Instance.Detatch(); WriteLine(new ConsoleString(output)); return(Task.CompletedTask); }
public void ArgActionInvokeThrowsOnNullAction() { var args = new string[] { }; var argAction = new ArgAction <ActionTestArgs>(); // Not setting .ActionArgs or .Args to leave them as null. try { argAction.Invoke(); Assert.Fail("Should have thrown an exception."); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(MissingArgException)); Assert.AreEqual("No action was specified", ex.Message); } }
public void ArgActionInvokeThrowsOnNullAction() { var args = new string[] { }; var argAction = new ArgAction<ActionTestArgs>(); // Not setting .ActionArgs or .Args to leave them as null. try { argAction.Invoke(); Assert.Fail("Should have thrown an exception."); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(MissingArgException)); Assert.AreEqual("No action was specified", ex.Message); } }
protected virtual Task <ConsoleString> Run(ArgAction toRun) { toRun.Invoke(); return(Task.FromResult("Command finished".ToCyan())); }
protected virtual Task Run(ArgAction toRun) { toRun.Invoke(); WriteLine("Command finished".ToCyan()); return(Task.CompletedTask); }
protected virtual Task Run(ArgAction toRun) { toRun.Invoke(); SetOutput(null); return(Task.CompletedTask); }